cd PARENT
for /D %%i in (*) do (
for /D %%j in (%%i*) do (
move "%%j*" "%%i\%%i.iso" 2>&1>nul && rmdir "%%j" 2>&1>nul
)
)
An explanation:
cd PARENT
Just make sure you're in the root directory to work from so the rest works
for /D %%i in (*) do (
This is a for loop, for every directory in the working directory it sets %%i to the directory name (e.g. FolderA), then does the following:
for /D %%j in (%%i*) do (
This is a nested for loop, for every directory in %%i (on first loop, FolderA) it sets %%j to the directory name (on first loop, FolderASubfolder01), then does the following:
move "%%j*.iso" "%%i\%%i.iso" 2>&1>nul && rmdir "%%j" 2>&1>nul
Move everything whose name ends with .iso
in %%j (FolderASubfolder01) to %%i (FolderA), and rename it to %%i.iso (FolderA.iso). If that works, remove the %%j directory. Redirect all output to nul
(i.e. produce no output).
)
)
Close off the loops.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…