DOS to move all files in subdirectories one level up

I have a folder with a large number of subfolders with one or more files in each. I am trying to write a batch file that moves all these files to C: \ songs (for example). Any help? I've already tried

C:\>FOR /RC:\Test %i IN (*) DO MOVE %i C:\Songs 

Test folders and songs exist, but I get an error

 %i was unexpected at this time. 

What am I doing wrong?

+7
source share
2 answers
 FOR /R %i IN (C:\Test\*) DO MOVE "%i" C:\Songs 

In a batch file, this should be %% i. Strange party quirk.

+5
source

(moving files in subdirectories up 1)

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

(in the last part I usually use backward biases, but this crazy thing deleted them for some reason. This will work anyway)

(delete unnecessary directories)

 for /d /r %x in (bin) do rd "%x" 

ie, if you had a group of directories with files in the bin directories according to these and you wanted to move everything to 1 and delete the bin directories.

+5
source

All Articles