[英]How to copy all files found with script to another folder using Windows Shell
I want to copy the files that are found from a search into a folder. 我想将通过搜索找到的文件复制到文件夹中。
The script where /r C:\\ *.jpg *.jpeg *.png *.gif >> C:\\output.txt
where /r C:\\ *.jpg *.jpeg *.png *.gif >> C:\\output.txt
的脚本
gives a text document with the location of the files I want. 提供带有所需文件位置的文本文档。 How can I create a copy of the files found from the search into some output folder X:\\output\\
如何将在搜索中找到的文件复制到某个输出文件夹X:\\ output \\
I want to get copies of all images in a folder including all subfolders into an output folder of all the images. 我想将一个文件夹(包括所有子文件夹)中的所有图像复制到所有图像的输出文件夹中。
You could get the output of a command with a for /f
loop: 您可以使用
for /f
循环获取命令的输出:
for /f "delims=" %%A in ('where /r C:\ *.jpg *.jpeg') do echo working on %%A
or process a file with: 或使用以下方法处理文件:
for /f "delims=" %%A in (C:\output.txt) do echo working on %%A
But for
is capable to do it itself: 但是
for
能够自己做到:
for /r "C:\" %%A in (*.jpg *.jpeg *.png *.gif) do ECHO copy "%%~fA" "X:\output\%%~nxA"
(remove the ECHO
after troubleshooting to actually enable the copy command) (在故障排除后删除
ECHO
,以实际启用复制命令)
Note: 注意:
- this doesn't take care of possible duplicate names. -这不会处理可能重复的名称。
- this is batch file syntax. -这是批处理文件语法。 For use on command line, replace every
%%
with a single %
要在命令行上使用,请用单个
%
替换每个%%
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.