I have multiple .rar files in multiple folders like this:




I want to move all of the .rar files to the parent directory 'C:\Docs'. I have a lot more than 3 folders, so I was thinking of making a batch file or something. What would be the commands to do this?

  • I searched for a similar issue and I found this answer to be useful.
    – lalthomas
    Jul 14, 2016 at 14:50

6 Answers 6


I've just made a commandline application that does exactly this (plus shows some stats) and searched to see if anybody was trying to do it so I could share it and save someone from having to figure it out.

It was a lot of fun to write. Requires .NET 3.5, works from the commandline, call with -h or no parameter for usage.

(source code)

Feedback a plus! :)

Oh, and screenshot of how it looks:


  • 3
    +1 Writing a program to solve someone's problem. That's commitment! Mar 17, 2012 at 9:14
  • 1
    @Li-aungYip Thank you very much for the compliment! Also, due to circumstances, I no longer have the hard drive where I used to code in the time I made this (having lost this and many other things), so I'm quite happy to see it here and have downloaded it now (kudos for Mediafire for storing it for so long with few downloads, and I'm lucky I didn't store it in Megaupload!). So if you put it in perspective, the more you give the more you receive :) Mar 17, 2012 at 10:26
  • Great work! +1 and 50 rep. I know this is 4.5 years old, but this was very useful for me because I downloaded 90+ files that went in 90+ folders. This helped me to put all the files in its parent folder.
    – user119782
    Jul 12, 2015 at 20:40
  • The only critique I have is that when I tried to use this, an error about a problem with the folder kept coming up, and it didn't state why. Only by using the -t command, I was able to determine why there was a problem with the folder (because it was named with 250+ characters). This is easily circumvented by highlighting all the folders and renaming one of them (then the rest will be appended with a number).
    – user119782
    Jul 12, 2015 at 20:43
  • @edmastermind29 I'm super happy to know that such an old code of mine has been of use to someone still. Believe it or not, the source code archive was taken off of mediafire for being auto-flagged as copyright infringement (which is pretty absurd, considering there's no video or audio but just text there), and I'm clueless about how I made this. If it's of any use, at this point I'd write a bash one-liner to deal with a problem like this, something like mv dir/sub/* dir; rmdir dir/sub in a loop. Jul 13, 2015 at 20:54

Give this a try:

for /d %f in (docs\*) do (
pushd %f
move .\*.* ..
  • Can you explain this a little more?
    – Nick
    Aug 25, 2010 at 15:16
  • @Nick: For all folders in docs, enter folder. Move all files from current folder to parent folder. Return to parent folder.
    – Hello71
    Aug 25, 2010 at 19:48
  • The pushd and popd isn't really necessary. cd would work just fine.
    – Hello71
    Aug 25, 2010 at 19:49
  • As explained by Hello71. Also, could be done with a single line: for /d %f in (docs\\*) do move %f\\*.* docs
    – BillP3rd
    Aug 25, 2010 at 20:45
  • 1
    NB. Neither the original above nor the one-liner will deal properly with duplicate file names.
    – BillP3rd
    Aug 25, 2010 at 20:47

Well, the answer for your question is very simple. Its not a script but it will do.

I assumed that you are running windows.

  • Place youself in C:\Docs directory
  • Press F3 (search)
  • Search for *.rar
  • Press Crtl+A
  • Press Ctrl+X
  • Close search window and one again go to C:\Dosc in explorer
  • Paste cutted files by pressing CTRL+V.
  • +1 for nice and simple workaround without any 3rd party or scripts. Oct 14, 2014 at 1:51
  • + 1 best and fastest method A+++ Sep 6, 2017 at 5:48

Suction worked for me on this issue.

Suction is a free, portable app that will help sort out messy folders in no time at all.

Suction works by consolidating parent directories. For example, if your images directory is full of unnecessary folders, drag the folder into the Suction interface, and it will do away with the folders, leaving you just with the files. This is also useful for people who download a lot of stuff.


Examples of copying or moving files from sub-directories to a single directory:

for /f "tokens=*" %a in ('dir "C:\Temp\Epub\*.epub" /s /b') do copy /y "%a" C:\Temp\epub\.

for /f "tokens=*" %a in ('dir "C:\Temp\Epub\*.epub" /s /b') do move /y "%a" C:\Temp\epub

the "tokens=* s to capture paths with special characters.


This should work:

move C:\Docs\*\* C:\Docs
  • 2
    I get the error: the filename, directory name, or volume label syntax is incorrect.
    – Nick
    Aug 25, 2010 at 15:07
  • The ** did not work
    – Nick
    Aug 25, 2010 at 15:14
  • You need to make sure you put the `\` in, and that it's not being escaped by your text editor.
    – Hello71
    Aug 25, 2010 at 19:48
  • Issuing this command from a CMD prompt (in Windows 7) generates the error noted by Nick.
    – BillP3rd
    Aug 25, 2010 at 20:41
  • This won't work. * does not properly work for folders. Gotta break out the third party programs like Total Commander.
    – surfasb
    Feb 15, 2011 at 12:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .