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"
See here also http://superuser.com/questions/496765/how-can-i-flatten-out-a-folder-in-windows-7-assuming-all-file-names-are-differe
– Matthew Lock – 2014-03-26T00:17:44.173