Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 962
Rishi Avatar asked Jan 15 '11 18:01

Rishi


1 Answers

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

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

like image 163
SilverbackNet Avatar answered Dec 05 '22 03:12

SilverbackNet