Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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
up vote 6 down vote accepted

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\
share|improve this answer
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 posting your answer, you agree to the privacy policy and terms of service.

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