简体   繁体   English

替换目录中的所有文件

[英]Replace all files in a directory

So basically what I'd like to do, is replace all the files in a directory with another file. 所以基本上我想做的是用另一个文件替换目录中的所有文件。

Example : I've got a folder with a.jpg, b.jpg and c.jpg, and a file named d.jpg outside of the folder. 示例:我有一个包含a.jpg,b.jpg和c.jpg的文件夹,并且在该文件夹之外有一个名为d.jpg的文件。 What I want to do is : Copy d.jpg Past it in the right directory Rename it a.jpg Paste it again Rename it b.jpg Paste it again Etc... 我想做的是:复制d.jpg粘贴到正确的目录中重命名a.jpg再次粘贴重命名b.jpg再次粘贴等...

I don't know how to do that, I think a .bat file could do that, but how? 我不知道该怎么办,我认为.bat文件可以做到这一点,但是怎么办? Thanks in advance. 提前致谢。

In a .bat file, loop *.jpg and copy the new image to the same name; 在.bat文件中,循环* .jpg并将新图像复制到相同的名称;

for %%f in ("c:\target\*.jpg") do (
    copy "c:\replacement\d.jpg" "%%f"
)

Obviously this irreversibly overwrites all c:\\target*.jpg files. 显然,这将不可逆转地覆盖所有c:\\ target * .jpg文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM