将相同文件名从不同文件夹复制到新文件夹时,追加文件名的循环 [英] Loop that appends filename when copying same filename from different folders to a new folder
本文介绍了将相同文件名从不同文件夹复制到新文件夹时,追加文件名的循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码来搜索多个文件夹中的特定文件名(ratings.zil),并将其复制到新文件夹中:
I have the following code to search for a specific file name (ratings.zil) across multiple folders and copy them to a new folder:
for /R %f in (ratings.zil) do @IF EXIST %f copy "%f" "C:\here"
但是,当文件复制到新文件夹时,它将覆盖而不是在每个ratings.zil
的末尾附加数字-即ratings(1).zil
,ratings(2).zil
.有没有一种方法可以在上述代码中添加一个循环,该循环将在每个文件后附加一个数字?
But when the file copies to the new folder it overwrites instead of appending a number at the end of each ratings.zil
– i.e. ratings(1).zil
, ratings(2).zil
. Is there a way to add a loop to the above code that will append a number after each file?
该问题最初被标记为重复问题,但重复问题的答案仅在您在同一文件夹中复制文件时才有效.
This question was originally marked as a duplicate, except the answer for the duplicate only works when you’re copying a file within the same folder.
推荐答案
查看全文