Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I recursively copy files of a specific pattern into a single flat folder on Windows?

I need to copy a set of DLL and PDB files from a set of folders recursively into another folder. I don't want to recreate the folder hierarchy in the target folder. I want to use built in Windows tools, e.g. DOS commands.

like image 445
mickdelaney Avatar asked Oct 29 '08 12:10

mickdelaney


People also ask

How do you remove all files from subfolders and relocate them to one folder?

In the search box (top right), type NOT kind:folder . You will now see a list of all files in your current folder and all its subfolders. Use Control-A to select all the files. Now you can move them all to another folder.

How do I copy a recursive file in Windows?

Use xcopy with /S switch to copy all files and directories recursively.

How do I copy a recursive file?

In order to copy the content of a directory recursively, you have to use the “cp” command with the “-R” option and specify the source directory followed by a wildcard character.


2 Answers

mkdir targetDir for /r %x in (*.dll, *pdb) do copy "%x" targetDir\ 

Use /Y at the end of the above command if you are copying multiple files and don't want to keep answering "Yes".

like image 68
Alexander Prokofyev Avatar answered Oct 03 '22 03:10

Alexander Prokofyev


command XCOPY

example of copying folder recursively:

mkdir DestFolder xcopy SrcFolder DestFolder /E 

(as stated below in the comment following WIKI that command was made available since DOS 3.2)

like image 44
Bronek Avatar answered Oct 03 '22 04:10

Bronek