Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xcopy directories and subdirectories recursively and filter only filenames by extension

Here is what i have for now:

xcopy "c:\projects\SampleProject" "c:\temp\copytest" /E /H /EXCLUDE:elist.txt 

It does all the job i need except filtering filenames by extensions.

For example: copy all *.exe files from c:\temp\copytest and subdirectories.

How to do that?

like image 474
DxCK Avatar asked Jun 01 '10 18:06

DxCK


People also ask

Does xcopy create directories?

With Xcopy, you can copy files and create the destination directory on the fly. To do so, you need to append the /I option to the Xcopy command. For example, the command below copies the files from the C:\Workarea\Demo folder to the D:\Workarea folder.

Is xcopy recursive?

To copy a single file or multiple files recursively with the Windows command prompt, use the xcopy command. The xcopy command is very similar to the copy command but it handles recursion and has many other options mainly related to recursion.

Does specify a file or directory xcopy?

By default, xcopy prompts you to specify whether Destination is a file or a directory. Copies directories and subdirectories, unless they are empty. If you omit /s, xcopy works within a single directory. Copies all subdirectories, even if they are empty.


1 Answers

I happened to need this too, and found out that if you want to xcopy files with specific type to a new folder keeping the current folder structure you need only to do this

xcopy [SourcePath]*.mp3 [DestinationPath]  /sy 

/s: Copies directories and subdirectories, unless they are empty. If you omit /s, xcopy works within a single directory.

/y : Suppresses prompting to confirm that you want to overwrite an existing destination file

Documentation

like image 80
pollirrata Avatar answered Sep 18 '22 14:09

pollirrata