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 all Ms office, Doc, xls, ppt, file scatter all over in different directories on my external hardrive I would like to move them to one director all *.doc & *.docx in a word directory with a sub directory where the come from *.xls & *.xlsx in a excel directory with a sub directory where the come from same with all the other types of MS office documents

In c:\ I create a directory c:\msdoc\ Under the msdoc instead of manually create a sub-directory the batch file create automatically the sub directory where the files come from

say I have file in c:\afiles\minopex then the batch file should create under c:\msdoc\ the sub-directory minopox and move all the *.doc to the new location the same for all other type of files

How can i write a batch file to do this

share|improve this question

you can - use a for loop with /r for recursivly parsing a directory - use %%f in collection (e.g. *.xls) to grab the files from the for loop - use the move-command to move files to a specific directory.

so for doc files it would be a one liner, for xls you could use a second line and so on...

share|improve this answer
I am a bit green on the cmd input can you give me a example – John Lockem Dec 5 '12 at 15:38

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.