# Windows Command Prompt: Moving multiple sub-files to their respective parent folders

So, I would like to achieve the following: The file structure currently looks like this:

Parent

Folder A

  Folder Aa

File 1


Folder B

  Folder Bb

File 2


Folder C

  Folder Cc

File 3


and I would like to run a command which converts this into:

Parent

Folder A

  Folder Aa

File 1


Folder B

  Folder Bb

File 2


Folder C

  Folder Cc

File 3


i.e. the files have simply been moved up to their respective parent folders. I have found code where you can group many sub-files into one single folder, but not where they all go into their individual folders. I guess it would be a variation of: for %F in (c:\foo\bar*.*) do move /Y %F c:\foo ?

Any help would be much appreciated!

• Are there files at any level other than the bottom level? – EBGreen Apr 12 '18 at 12:40
• No, folders A, B, C are empty other than the folder within it (which are useless and just causing problems!) :-) – Hashamyim Apr 12 '18 at 12:41

Create a simple .bat file in the directory where all FolderA, FolderB, ... reside

@echo off

for /D %%f in (Folder*) do (
for /D %%g in (%%f\*) do (
move %%g\*.* %%f
)
)


this loops on the directories, then on the inner directories, and apply the global move command of all files one level up.

• That is brilliant - thanks ever so much :-) – Hashamyim Apr 13 '18 at 14:41