批量重命名/复制/删除不起作用?

时间:2022-11-07 07:32:43

On whatever reason this is not working (says 'file not found'),

无论出于什么原因,这都行不通(说'找不到文件'),

set in=c:\myprogram\_save
cd %temp%
ren 1RO.dat "Titanic Moves 1 of 3 Rotterdam.dat"
ren 12RO.img "Titanic Moves 1 of 3 Rotterdam.img"
ren 2HA.dat "Titanic Moves 2 of 3 Hawai.dat"
ren 22HA.img "Titanic Moves 2 of 3 Hawai.img"
ren 3NY.dat "Titanic Moves 3 of 3 NY.dat"
ren 33NY.img "Titanic Moves 3 of 3 NY.img"
copy "Titanic Moves 1 of 3 Rotterdam.dat" "%in%"
copy "Titanic Moves 1 of 3 Rotterdam.img" "%in%"
copy "Titanic Moves 2 of 3 Rotterdam.dat" "%in%"
copy "Titanic Moves 2 of 3 Rotterdam.img" "%in%"
copy "Titanic Moves 3 of 3 Rotterdam.dat" "%in%"
copy "Titanic Moves 3 of 3 Rotterdam.img" "%in%"
del "Titanic Moves 1 of 3 Rotterdam.dat"
del "Titanic Moves 1 of 3 Rotterdam.img"
del "Titanic Moves 2 of 3 Rotterdam.dat"
del "Titanic Moves 2 of 3 Rotterdam.img"
del "Titanic Moves 3 of 3 Rotterdam.dat"
del "Titanic Moves 3 of 3 Rotterdam.img"

This is what's happening before [helper45 = 7zip commandline executable],

这是[helper45 = 7zip命令行可执行文件]之前发生的事情,

ren package.temp package.zip
copy package.zip %temp%
del package.zip
helper45 e "%temp%\package.zip"

'e' is the extract command.

'e'是提取命令。

3 个解决方案

#1


I just noticed an obvious error. If that script is literally what you have, then the error is below. If it is not, I'm sure as hell going to downvote the question for providing incorrect information.

我刚注意到一个明显的错误。如果该脚本实际上是您所拥有的,那么错误就在下面。如果不是,我肯定会因为提供不正确的信息而无法提出问题。

Anyway, look below.

无论如何,看下面。

Two Rotterdam files (1 of 3):

两个鹿特丹文件(1/3):

ren 1RO.dat "Titanic Moves 1 of 3 Rotterdam.dat"
ren 12RO.img "Titanic Moves 1 of 3 Rotterdam.img"

Two Hawai files (2 of 3):

两个夏威夷文件(2/3):

ren 2HA.dat "Titanic Moves 2 of 3 Hawai.dat"
ren 22HA.img "Titanic Moves 2 of 3 Hawai.img"

Two NY files (3 of 3):

两个NY文件(3个中的3个):

ren 3NY.dat "Titanic Moves 3 of 3 NY.dat"
ren 33NY.img "Titanic Moves 3 of 3 NY.img"

Two Rotterdam files (1 of 3):

两个鹿特丹文件(1/3):

copy "Titanic Moves 1 of 3 Rotterdam.dat" "%in%"
copy "Titanic Moves 1 of 3 Rotterdam.img" "%in%"

Another two Rotterdam files, 2 of 3 -- but the "2 of 3" files above are Hawai!

另外两个鹿特丹文件,2个中的3个 - 但上面的“2个3”文件是夏威夷!

copy "Titanic Moves 2 of 3 Rotterdam.dat" "%in%"
copy "Titanic Moves 2 of 3 Rotterdam.img" "%in%"

Still two more Rotterdam files, 3 of 3 -- but the "3 of 3" files above are NY!

还有两个鹿特丹文件,3个中的3个 - 但上面的“3个3”文件是纽约!

copy "Titanic Moves 3 of 3 Rotterdam.dat" "%in%"
copy "Titanic Moves 3 of 3 Rotterdam.img" "%in%"

The same error is present in the lines below:

以下行中出现相同的错误:

del "Titanic Moves 1 of 3 Rotterdam.dat"
del "Titanic Moves 1 of 3 Rotterdam.img"
del "Titanic Moves 2 of 3 Rotterdam.dat"
del "Titanic Moves 2 of 3 Rotterdam.img"
del "Titanic Moves 3 of 3 Rotterdam.dat"
del "Titanic Moves 3 of 3 Rotterdam.img"

If that doesn't help, remove any "@echo off" from the batch file, and show us a copy&paste from the error with the line it happens at.

如果这没有帮助,请从批处理文件中删除任何“@echo off”,并向我们显示错误的复制和粘贴,并显示它所在的行。

#2


I'd suspect at least one of the files you are trying to copy/delete do not exist. You can see which line gives that error by looking directly above the error message (and removing the echo off from the batch, if there is one).

我怀疑您尝试复制/删除的文件中至少有一个不存在。您可以通过直接查看错误消息(以及从批处理中删除回显,如果有的话)来查看哪条行给出了该错误。

Furthermore, why are you doing rename, copy and delete operations in that order? You can just as easily roll them all into one move operation per file:

此外,为什么要按顺序重命名,复制和删除操作?您可以轻松地将它们全部转换为每个文件的一个移动操作:

move 1RO.dat "%in%\Titanic Moves 1 of 3 Rotterdam.dat"
move 12RO.img "%in%\Titanic Moves 1 of 3 Rotterdam.img"
move 2HA.dat "%in%\Titanic Moves 2 of 3 Hawai.dat"
move 22HA.img "%in%\Titanic Moves 2 of 3 Hawai.img"
move 3NY.dat "%in%\Titanic Moves 3 of 3 NY.dat"
move 33NY.img "%in%\Titanic Moves 3 of 3 NY.img"

#3


I would use pushd instead of cd so that if you are calling it from a different drive it works.

我会使用pushd而不是cd,这样如果你从不同的驱动器调用它就可以了。

#1


I just noticed an obvious error. If that script is literally what you have, then the error is below. If it is not, I'm sure as hell going to downvote the question for providing incorrect information.

我刚注意到一个明显的错误。如果该脚本实际上是您所拥有的,那么错误就在下面。如果不是,我肯定会因为提供不正确的信息而无法提出问题。

Anyway, look below.

无论如何,看下面。

Two Rotterdam files (1 of 3):

两个鹿特丹文件(1/3):

ren 1RO.dat "Titanic Moves 1 of 3 Rotterdam.dat"
ren 12RO.img "Titanic Moves 1 of 3 Rotterdam.img"

Two Hawai files (2 of 3):

两个夏威夷文件(2/3):

ren 2HA.dat "Titanic Moves 2 of 3 Hawai.dat"
ren 22HA.img "Titanic Moves 2 of 3 Hawai.img"

Two NY files (3 of 3):

两个NY文件(3个中的3个):

ren 3NY.dat "Titanic Moves 3 of 3 NY.dat"
ren 33NY.img "Titanic Moves 3 of 3 NY.img"

Two Rotterdam files (1 of 3):

两个鹿特丹文件(1/3):

copy "Titanic Moves 1 of 3 Rotterdam.dat" "%in%"
copy "Titanic Moves 1 of 3 Rotterdam.img" "%in%"

Another two Rotterdam files, 2 of 3 -- but the "2 of 3" files above are Hawai!

另外两个鹿特丹文件,2个中的3个 - 但上面的“2个3”文件是夏威夷!

copy "Titanic Moves 2 of 3 Rotterdam.dat" "%in%"
copy "Titanic Moves 2 of 3 Rotterdam.img" "%in%"

Still two more Rotterdam files, 3 of 3 -- but the "3 of 3" files above are NY!

还有两个鹿特丹文件,3个中的3个 - 但上面的“3个3”文件是纽约!

copy "Titanic Moves 3 of 3 Rotterdam.dat" "%in%"
copy "Titanic Moves 3 of 3 Rotterdam.img" "%in%"

The same error is present in the lines below:

以下行中出现相同的错误:

del "Titanic Moves 1 of 3 Rotterdam.dat"
del "Titanic Moves 1 of 3 Rotterdam.img"
del "Titanic Moves 2 of 3 Rotterdam.dat"
del "Titanic Moves 2 of 3 Rotterdam.img"
del "Titanic Moves 3 of 3 Rotterdam.dat"
del "Titanic Moves 3 of 3 Rotterdam.img"

If that doesn't help, remove any "@echo off" from the batch file, and show us a copy&paste from the error with the line it happens at.

如果这没有帮助,请从批处理文件中删除任何“@echo off”,并向我们显示错误的复制和粘贴,并显示它所在的行。

#2


I'd suspect at least one of the files you are trying to copy/delete do not exist. You can see which line gives that error by looking directly above the error message (and removing the echo off from the batch, if there is one).

我怀疑您尝试复制/删除的文件中至少有一个不存在。您可以通过直接查看错误消息(以及从批处理中删除回显,如果有的话)来查看哪条行给出了该错误。

Furthermore, why are you doing rename, copy and delete operations in that order? You can just as easily roll them all into one move operation per file:

此外,为什么要按顺序重命名,复制和删除操作?您可以轻松地将它们全部转换为每个文件的一个移动操作:

move 1RO.dat "%in%\Titanic Moves 1 of 3 Rotterdam.dat"
move 12RO.img "%in%\Titanic Moves 1 of 3 Rotterdam.img"
move 2HA.dat "%in%\Titanic Moves 2 of 3 Hawai.dat"
move 22HA.img "%in%\Titanic Moves 2 of 3 Hawai.img"
move 3NY.dat "%in%\Titanic Moves 3 of 3 NY.dat"
move 33NY.img "%in%\Titanic Moves 3 of 3 NY.img"

#3


I would use pushd instead of cd so that if you are calling it from a different drive it works.

我会使用pushd而不是cd,这样如果你从不同的驱动器调用它就可以了。