1

I have a Windows Directory with about 8000 subdirectories. In each subdirectory there is a single zip file. Is there a way I can batch script the move of each zip file to be moved to the parent directory, and then delete the subdirectory it was in? (Sub folder) I know I can use xcopy to move files, but I'm not sure how to loop through the entire directory of sub directories. Thank you!

1 Answers1

1
@ECHO OFF &SETLOCAL
FOR /f "delims=" %%a IN ('dir /b /a-d /s *.zip') DO (
    MOVE "%%~fa" ..
    RD "%%~dpa"
)
Endoro
  • 37,015
  • 8
  • 50
  • 63
  • This might suffer from the FOR problem where the filespec is processed multiple times. It is probably processing them as it goes. A solution is to use the `FOR /F` command. – foxidrive Aug 23 '13 at 00:06