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.

In Windows, is there a way (built in or using a 3rd party program) to bulk move all the contents of subfolders up a level? In other words, a way to get rid of selected subfolders while keeping their contents? I'd like to go from:

Folder
  Subfolder1
    File1
  Subfolder2
    File2

To:

Folder
  File1
  File2

In a single process.

share|improve this question
    
Thank you to everyone for your help! –  George MacDonald Jan 3 '10 at 16:03
    
See here also superuser.com/questions/496765/… –  Matthew Lock Mar 26 at 0:17

5 Answers 5

up vote 4 down vote accepted

You can use a for loop in the command prompt:

for /r %i in (*) do @move "%i" .

Yes, it will try to move files in the current directory, back to the current directory, but that doesn't cause any harm. Make sure you run it while situated in the top of the hierarchy you want to move the files to. Running this from another location will have very undesired effects.

If you wish to run it so that you do not have to be in a certain directory, you can type out the paths:

for /r C:\path %i in (*) do @move "%i" "C:\path"

replace C:\path with the location of the top directory that all the files will be moved to. If you wish to run it in a batch script, change the variables to include another percent sign:

for /r C:\path %%i in (*) do @move "%%i" "C:\path"

to remove all of the empty subdirectories (from cmd):

for /d %i in (C:\path\*) do @rmdir /s /q "%i"

from batch:

for /d %%i in (C:\path\*) do @rmdir /s /q "%%i"
share|improve this answer
    
I felt forced to edit your post as what you proposed would result in pretty nasty file loss. First, using delims=? is dangerous since the default settings of console windows on Windows use raster fonts which cause every Unicode character that doesn't fit into the legacy OEM codepage to be printed as ?. And you were iterating over output ... Using for /f is the wrong idiom anyway here. for can iterate over files, recursively or directories just fine and it will correctly handle Unicode filenames even with raster fonts. 600 chars is to short for a proper explanation of the subject :-( –  Joey Dec 21 '09 at 8:24
    
forgot about unicode :( thanks though. –  John T Dec 21 '09 at 18:47
    
By the way, "delims=" is perfectly acceptable and works. You don't have to find a character that is unlikely in the output :-) –  Joey Dec 22 '09 at 8:00

A simple way (in XP) is to right click on the root folder and select Search, then enter no criteria and press Search. The search results will be a flattened list of what's in the folder and subfolders. You can then just drag the results of the search into another folder and all the files will be "removed" from their folders.

In versions of Windows after XP you can achieve the same effect by just entering a search term in the search box on the top right of an Explorer Window, and then copying the results to another folder.

share|improve this answer
    
Is this Search command a right click option? And is it only in XP and not in Vista or 7? –  George MacDonald Dec 22 '09 at 14:48

Loads of good suggestions so far. You could also use Everything. Right click on the relevant parent folder, "search everything". This will give a list of, well, everything in the folder. You can perform the moving operations from here, perhaps after sorting by file type, or including a file type in the search, to exclude the folders.

share|improve this answer
    
"Everything" is great. The "content" style searches in Vista onwards aren't as good as exhausted search by file name. –  Matthew Lock Mar 26 at 0:16

You could do this using batch files and the 'move' command.

have a read of this thread.

share|improve this answer

You can get Total Commander, which is a shareware file management program, go into your folder, press Ctrl + B (meaning branch all subdirectories - it will display all files in this directory and all subdirectories), select everything and copy to your desired location (i.e. one folder higher).

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.