简体   繁体   中英

Want to batch move all files from directories into the parent directory and delete the subdirectory

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!

@ECHO OFF &SETLOCAL
FOR /f "delims=" %%a IN ('dir /b /a-d /s *.zip') DO (
    MOVE "%%~fa" ..
    RD "%%~dpa"
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM