How to Move Files From Multiple Folders Into One Folder

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:

answered Dec 27 '10 at 21:42

6

  • +1 Writing a program to solve someone's problem. That's commitment!

    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 :)

    Mar 17 '12 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 '15 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 '15 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 '15 at 20:54

Give this a try:

                for /d %f in (docs\*) do ( pushd %f move .\*.* .. popd )                              

answered Aug 25 '10 at 14:57

6

  • Can you explain this a little more?

    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.

    Aug 25 '10 at 19:48

  • The pushd and popd isn't really necessary. cd would work just fine.

    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

    Aug 25 '10 at 20:45

  • NB. Neither the original above nor the one-liner will deal properly with duplicate file names.

    Aug 25 '10 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.

answered Mar 17 '12 at 7:33

2

  • +1 for nice and simple workaround without any 3rd party or scripts.

    Oct 14 '14 at 1:51

  • + 1 best and fastest method A+++

    Sep 6 '17 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.

answered Mar 17 '12 at 3:02

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.

answered Jul 3 '14 at 3:46

This should work:

                move C:\Docs\*\* C:\Docs                              

answered Aug 25 '10 at 14:52

5

  • I get the error: the filename, directory name, or volume label syntax is incorrect.

    Aug 25 '10 at 15:07

  • The ** did not work

    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.

    Aug 25 '10 at 19:48

  • Issuing this command from a CMD prompt (in Windows 7) generates the error noted by Nick.

    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.

    Feb 15 '11 at 12:52

Not the answer you're looking for? Browse other questions tagged windows-7 command-line file-management file-transfer or ask your own question.

How to Move Files From Multiple Folders Into One Folder

Source: https://superuser.com/questions/180573/move-files-from-multiple-folders-all-into-parent-directory-with-command-prompt

0 Response to "How to Move Files From Multiple Folders Into One Folder"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel