开发者

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?


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

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


(move files in sub-directories up 1)

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

(last part I usually use backward slants but this crazy thing kept deleting them for some reason. It'll work either way though)

(delete unneeded directories)

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

i.e., if you had a bunch of directories with files in "bin" directories under those and you wanted to move everything up 1 and delete the "bin" directories.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜