如何复制使用批处理文件只有文件(不是目录)? [英] How to copy only files(not directories) using batch file?
本文介绍了如何复制使用批处理文件只有文件(不是目录)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
的目录结构是:
Images
-Folder1
-image1.jpg
-image2.jpg
-Folder2
-image3.jpg
-image4.png
-Folder3
-image6.png
-image7.jpg
-Folder4
我要复制的所有图像(即* .JPG,* .PNG)只有文件(不是文件夹)到父目录(图像)。
I want to copy all images(i.e *.jpg, *.png) files only (not the folders) into the parent directory("Images").
我一直在使用的Robocopy尝试如下:
I have tried using "robocopy" as follows:
robocopy /np ..\..\Exam\Images ..\..\Exam\Images *.jpg *.png /S
下面的所有文件,以及为文件夹复制:(。但我需要复制的文件。如何做到这一点?
Here all files as well as folders are copied :(. But I need only files to be copied. How to do this?
许多许多在此先感谢!
推荐答案
试试这个命令行:
for /r "Images" %i in (*.jpg *.png) do copy "%~fi" "my\target folder"
有关巴赫的脚本%
必须加倍 %%
。
For a bach script the %
must be doubled %%
.
这篇关于如何复制使用批处理文件只有文件(不是目录)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文