Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

C:\Docs\Folder1\rarfile1-1.rar
C:\Docs\Folder1\rarfile1-2.rar
C:\Docs\Folder1\rarfile1-3.rar  

C:\Docs\Folder2\rarfile2-1.rar
C:\Docs\Folder2\rarfile2-2.rar
C:\Docs\Folder2\rarfile2-3.rar  

C:\Docs\Folder3\rarfile3-1.rar
C:\Docs\Folder3\rarfile3-2.rar
C:\Docs\Folder3\rarfile3-3.rar  

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?
Thanks

share|improve this question

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.

MoveFilesUpFromSubfolders
(source code)

Feedback a plus! :)

Oh, and screenshot of how it looks:

                               

share|improve this answer
    
+1 Writing a program to solve someone's problem. That's commitment! –  Li-aung Yip Mar 17 '12 at 9:14
    
@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 :) –  Camilo Martin Mar 17 '12 at 10:26

Give this a try:

for /d %f in (docs\*) do (
pushd %f
move .\*.* ..
popd
)
share|improve this answer
    
Can you explain this a little more? –  Nick Aug 25 '10 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 '10 at 19:48
    
The pushd and popd isn't really necessary. cd would work just fine. –  Hello71 Aug 25 '10 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 '10 at 20:45
    
NB. Neither the original above nor the one-liner will deal properly with duplicate file names. –  BillP3rd Aug 25 '10 at 20:47

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.

share|improve this answer

This should work:

move C:\Docs\*\* C:\Docs
share|improve this answer
    
I get the error: the filename, directory name, or volume label syntax is incorrect. –  Nick Aug 25 '10 at 15:07
    
The ** did not work –  Nick Aug 25 '10 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 '10 at 19:48
    
Issuing this command from a CMD prompt (in Windows 7) generates the error noted by Nick. –  BillP3rd Aug 25 '10 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 '11 at 12:52

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.
share|improve this answer

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=* is to capture paths with special characters

share|improve this answer

Your Answer

 
discard

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.