BAT文件重命名不同目录中的相同文件并复制新文件

时间:2016-11-15 11:17:15

标签: batch-file copy rename

我目前处于这种情况:

C:\Parent\Child\A\Sub\file.html
C:\Parent\Child\B\Sub\file.html
C:\Parent\Child\C\file.html
C:\Parent\Child\D\file.html
C:\Parent\Child\E\file.html
C:\Parent\Child\F\file.html

我需要创建一个.bat文件,将所有file.html重命名为file.html.BAK。 然后,我需要从file.html复制新的C:\Parent\Child\并将其粘贴到上面写的位置。

我已经尝试做了一些事情,结果就是这样:

@echo off

set "Folder=C:\Parent\Child\A\Sub"
ren file.html file.html.BAK
copy C:\Parent\Child\file.html C:\Parent\Child\A\Sub

set "Folder=C:\Parent\Child\B\Sub"
ren file.html file.html.BAK
copy C:\Parent\Child\file.html C:\Parent\Child\B\Sub

set "Folder=C:\Parent\Child\C"
ren file.html file.html.BAK
copy C:\Parent\Child\file.html C:\Parent\Child\C

set "C:\Parent\Child\D"
ren file.html file.html.BAK
copy C:\Parent\Child\file.html C:\Parent\Child\D

set "Folder=C:\Parent\Child\E"
ren file.html file.html.BAK
copy C:\Parent\Child\file.html C:\Parent\Child\E

set "Folder=C:\Parent\Child\F"
ren file.html file.html.BAK
copy C:\Parent\Child\file.html C:\Parent\Child\F

pause
exit

我不确定这是否有效,如果这是最好的方法。

0 个答案:

没有答案
相关问题