我想创建一个批处理脚本,将一个目录下的子文件夹中的所有usr文件复制到2个单独的文件夹中,然后将文件从原来的地方删除。到目前为止,我已经做到了。
for /R S:\Customer Services\EDI\NET EDI %%f in (*.usr) do copy T:\edidata\netedi\Outboxtest
for /R S:\Customer Services\EDI\NET EDI %%f in (*.usr) do copy T:\edidata\netedi\Outbox backup
但这并没有复制文件,也没有发生任何事情 我到底哪里出错了?那我需要添加什么才能把文件也从原来的文件夹中删除呢?
编辑一下
从我读到的答案来看,我认为应该是这样的:
for /R "S:\Customer Services\EDI\NET EDI" %%f in (*.usr) do copy %%F "T:\edidata\netedi\Outboxtest"
for /R "S:\Customer Services\EDI\NET EDI" %%f in (*.usr) do copy %%F "T:\edidata\netedi\Outbox backup"
但还是不行 我想我只是还没有正确理解所说的内容吧
编辑2:
我添加了PAUSE命令在脚本的结尾,看看发生了什么,当它被运行,这是什么出现了。
S:\Customer Services\EDI\NET EDI>for /R "S:\Customer Services\EDI\NET EDI" %f in (*.usr) do copy %F "T:\edidata\netedi\Outboxtest"
S:\Customer Services\EDI\NET EDI>copy %F "T:\edidata\netedi\Outboxtest"
The system cannot find the file specified.
S:\Customer Services\EDI\NET EDI>copy %F "T:\edidata\netedi\Outboxtest"
The system cannot find the file specified.
S:\Customer Services\EDI\NET EDI>copy %F "T:\edidata\netedi\Outboxtest"
The system cannot find the file specified.
S:\Customer Services\EDI\NET EDI>copy %F "T:\edidata\netedi\Outboxtest"
The system cannot find the file specified.
S:\Customer Services\EDI\NET EDI>copy %F "T:\edidata\netedi\Outboxtest"
The system cannot find the file specified.
S:\Customer Services\EDI\NET EDI>copy %F "T:\edidata\netedi\Outboxtest"
The system cannot find the file specified.
S:\Customer Services\EDI\NET EDI>copy %F "T:\edidata\netedi\Outboxtest"
The system cannot find the file specified.
S:\Customer Services\EDI\NET EDI>for /R "S:\Customer Services\EDI\NET EDI" %f in (*.usr) do copy %F "T:\edidata\netedi\Outbox backup"
S:\Customer Services\EDI\NET EDI>copy %F "T:\edidata\netedi\Outbox backup"
The system cannot find the file specified.
S:\Customer Services\EDI\NET EDI>copy %F "T:\edidata\netedi\Outbox backup"
The system cannot find the file specified.
S:\Customer Services\EDI\NET EDI>copy %F "T:\edidata\netedi\Outbox backup"
The system cannot find the file specified.
S:\Customer Services\EDI\NET EDI>copy %F "T:\edidata\netedi\Outbox backup"
The system cannot find the file specified.
S:\Customer Services\EDI\NET EDI>copy %F "T:\edidata\netedi\Outbox backup"
The system cannot find the file specified.
S:\Customer Services\EDI\NET EDI>copy %F "T:\edidata\netedi\Outbox backup"
The system cannot find the file specified.
S:\Customer Services\EDI\NET EDI>copy %F "T:\edidata\netedi\Outbox backup"
The system cannot find the file specified.
希望是最后的编辑。
现在我已经得到了
for /R "S:\Customer Services\EDI\NET EDI" %%G in (*.usr) do copy %%G "T:\edidata\NetEDI\Outboxtest"
for /R "S:\Customer Services\EDI\NET EDI" %%G in (*.usr) do copy %%G "T:\edidata\NetEdi\Outbox backup"
PAUSE
但它仍然不能正常工作,给出的输出是。
S:\Customer Services\EDI\NET EDI>for /R "S:\Customer Services\EDI\NET EDI" %G in (*.usr) do copy %G "T:\edidata\NetEDI\Outboxtest"
S:\Customer Services\EDI\NET EDI>copy S:\Customer Services\EDI\NET EDI\gentest.usr "T:\edidata\NetEDI\Outboxtest"
The system cannot find the file specified.
S:\Customer Services\EDI\NET EDI>copy S:\Customer Services\EDI\NET EDI\Asda\asdatest.usr "T:\edidata\NetEDI\Outboxtest"
The system cannot find the file specified.
S:\Customer Services\EDI\NET EDI>copy S:\Customer Services\EDI\NET EDI\Costcutter\CCINV24052020.usr "T:\edidata\NetEDI\Outboxtest"
The system cannot find the file specified.
S:\Customer Services\EDI\NET EDI>copy S:\Customer Services\EDI\NET EDI\Costcutter\cctest.usr "T:\edidata\NetEDI\Outboxtest"
The system cannot find the file specified.
S:\Customer Services\EDI\NET EDI>copy S:\Customer Services\EDI\NET EDI\McColls Local Account\mccollstest.usr "T:\edidata\NetEDI\Outboxtest"
The system cannot find the file specified.
S:\Customer Services\EDI\NET EDI>copy S:\Customer Services\EDI\NET EDI\Scotmid\scotmidtest.usr "T:\edidata\NetEDI\Outboxtest"
The system cannot find the file specified.
S:\Customer Services\EDI\NET EDI>copy S:\Customer Services\EDI\NET EDI\Tesco\tescotest.usr "T:\edidata\NetEDI\Outboxtest"
The system cannot find the file specified.
S:\Customer Services\EDI\NET EDI>for /R "S:\Customer Services\EDI\NET EDI" %G in (*.usr) do copy %G "T:\edidata\NetEdi\Outbox backup"
S:\Customer Services\EDI\NET EDI>copy S:\Customer Services\EDI\NET EDI\gentest.usr "T:\edidata\NetEdi\Outbox backup"
The system cannot find the file specified.
S:\Customer Services\EDI\NET EDI>copy S:\Customer Services\EDI\NET EDI\Asda\asdatest.usr "T:\edidata\NetEdi\Outbox backup"
The system cannot find the file specified.
S:\Customer Services\EDI\NET EDI>copy S:\Customer Services\EDI\NET EDI\Costcutter\CCINV24052020.usr "T:\edidata\NetEdi\Outbox backup"
The system cannot find the file specified.
S:\Customer Services\EDI\NET EDI>copy S:\Customer Services\EDI\NET EDI\Costcutter\cctest.usr "T:\edidata\NetEdi\Outbox backup"
The system cannot find the file specified.
S:\Customer Services\EDI\NET EDI>copy S:\Customer Services\EDI\NET EDI\McColls Local Account\mccollstest.usr "T:\edidata\NetEdi\Outbox backup"
The system cannot find the file specified.
S:\Customer Services\EDI\NET EDI>copy S:\Customer Services\EDI\NET EDI\Scotmid\scotmidtest.usr "T:\edidata\NetEdi\Outbox backup"
The system cannot find the file specified.
S:\Customer Services\EDI\NET EDI>copy S:\Customer Services\EDI\NET EDI\Tesco\tescotest.usr "T:\edidata\NetEdi\Outbox backup"
The system cannot find the file specified.
所以我的理解是,它现在得到了文件,但却找不到要复制的文件夹?他们两个的文件目的地都是正确的,我已经仔细检查过了,所以不知道还有什么问题。
你的命令中至少有三个问题。
你只提供了一个参数给 copy
命令。它需要 源头 和 目的地. 你可能忘了使用 %%F
提供的论据 for
.
for /R <path> %%f in (*.usr) do copy %%F T:\edidata\netedi\Outboxtest
另一个问题是,你的路径中包含空格,而你没有将它们转义。你应该用双引号包围你的路径。
"S:\Customer Services\EDI\NET EDI"
同样的问题很可能发生在 T:\edidata\netedi\Outbox backup
. 当前命令
for /R S:\Customer Services\EDI\NET EDI %%f in (*.usr) do copy T:\edidata\netedi\Outbox backup
将从 T:\edidata\netedi\Outbox
到 .\backup
.
你也必须为你的参数使用引号,因为在你的情况下,它将扩展到一个包含空格的路径。
... do copy "%%f" T:\edidata\netedi\Outboxtest
一般来说,最好使用下划线 (_
)或连字符(-
)而不是路径中的空格,那么你就不需要在每个命令中转义。
语句中的 %%f
参数是区分大小写的,它不能被引用为 %%F
.
我相信你应该这样做:
... copy %%f T:\edidata\netedi\Outboxtest\ (or ...Outbox\test\)
...那T:edidata\netedi\Outbox备份是怎么回事?是不是应该是::
... copy %%f T:\edidata\netedi\Outbox\backup\