I have 6 CDs with PDF files inside a lot of folders (Like Prep1, Prep2... and so on.)

I need to copy all the PDF files inside folders to my C:\ and then burn them all.

Is there a command in cmd Prompt that I can do that quick and flawlessly?

  • Clarify: do you need to keep CD/folder structure (/CD1/Prep1), folder structure (/Prep1), or all the PDFs in the root of CD? – Theo Apr 7 '11 at 13:35
  • No I don't need to. I just to have all the .PDF files in my destination folder. Sorry for the lack of info – r0ca Apr 7 '11 at 14:03

To loop through all folders and subfolders on drive D: and copy .pdf files to C:\myfolder without subdirectories try this:

C:\>for /R D:\ %G IN (*.pdf) DO xcopy "%G" C:\myfolder\

To replace existing files without a confirmation prompt use XCOPY /Y

C:\>for /R D:\ %G IN (*.pdf) DO xcopy /Y "%G" C:\myfolder\
  • Beat me to it! FYI I tested this--works. – Theo Apr 7 '11 at 14:14
  • Ok, that... is ... awsome! – r0ca Apr 7 '11 at 14:22
  • Is it possible to have the /switch to avoid to press Y (Yes) all the time to overwrite the duplicate file? – r0ca Apr 7 '11 at 15:26
  • @r0ca: yes, it's possible. Use XCOPY /Y option. I've updated my answer – Siim K Apr 7 '11 at 18:32
  • Awsome! I'll keep this command in mind! – r0ca Apr 8 '11 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.