8

I found that I can use xcopy /s to copy all files that match a wildcard combination in a folder to another location. But this command re-creates the folder structure. I do not want the tree. I need just the files dumped into the destination folder. There are no duplicate files in the source folder.

BZ1
  • 1,306
  • 2
  • 8
  • 10

2 Answers2

12

You can use for command:

for /R %%x in (*.cpp) do copy "%%x" "c:\dest\"

If you want to run it directly from command prompt (not from a batch file) use %x instead of %%x.

Sergey Podobry
  • 7,101
  • 1
  • 41
  • 51
2

For your purpose, instead of using xcopy you should use robocopy:

http://en.wikipedia.org/wiki/Robocopy

http://technet.microsoft.com/en-us/library/cc733145(WS.10).aspx

gingo
  • 468
  • 1
  • 4
  • 18
  • Robocopy seems to have a lot more options than xcopy. I didn't realise that it was a MS utility. Anyway, the command option to make look recursively says "Copies directories..." – BZ1 Sep 16 '11 at 08:22