Search code examples
windows-xpdosbatch-file

DOS command to move all files in subdirectories one level up


I have a folder with a lot of sub folders with one or more files in each. I am trying to write a batch file that moves all those files to C:\songs (for example). Any help? I have already tried

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

The folders Test and songs exist, but I get an error saying

%i was unexpected at this time. 

What am I doing wrong?


Solution

  • FOR /R %i IN (C:\Test\*) DO MOVE "%i" C:\Songs
    

    In a batch file, it has to be %%i. Weird quirk of batch.