简体   繁体   English

如何使用Windows Shell将使用脚本找到的所有文件复制到另一个文件夹

[英]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.

相关问题 如何使用shell脚本将文件从1个文件夹复制到另一个文件夹名称是动态的 - How to copy files from 1 folder to another where folders names are dynamic using shell script 如何使用Shell脚本将Directory中的文件复制到另一个Directory - How To Copy files in Directory to another Directory using shell script Shell脚本复制所有文件和子目录-带有空格的文件夹名称 - Shell Script Copy All Files and Subdirectories - Folder Names With Spaces 一个shell脚本来复制一个文件夹及其所有子文件夹,但请注意它是文件 - a shell script to copy a folder and all it's subfolders, but noit it's files [Unix] [Shell脚本]将所有文件从一个文件夹复制到另一个文件夹 - [Unix][Shell Script] Copy all files from one folder to the other Shell脚本将目录中的所有文件复制到指定的文件夹 - Shell Script to copy all files in a directory to a specified folder Shell脚本可提取目录及其子目录中的所有zip文件,并将提取的文件复制到具有相同层次结构的另一个文件夹中 - Shell script to extract all zip files in a directory and its sub directory, and copy the extracted files into another folder with same hierarchy shell如何对目录中的所有文件应用功能并将结果复制到另一个文件夹中? - shell how to apply a function to all the files in the directory and copy in another folder the results? 如何每天从文件夹中获取文件,然后使用Shell脚本将其存储在另一个文件夹中? - How to get the files from a folder everyday and store it in another folder using shell script? Windows Shell脚本扫描文件夹并复制文件 - Windows Shell Script to scan folder & copy file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM