1: 2: 3: 4: 5: 6:
set BaseDir=e:\hold0 set DestDir=e:\hold for /F "tokens=*" %%A in ('dir /ad /s /b "%BaseDir%"^|sort /r') do ( move "%%A\*.*" "%DestDir%" rd "%%A" )
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17:
@echo off setlocal EnableDelayedExpansion set BaseDir=e:\hold0 set DestDir=e:\hold set MaxFiles=100000 set Count=0 for /F "tokens=*" %%A in ('dir /ad /s /b "%BaseDir%"^|sort /r') do ( for %%B in ("%%A\*") do ( set /A Count += 1 if !Count! GTR %MaxFiles% ( echo Maximum of [%MaxFiles%] reached, stopping now. exit /b ) move "%%B" "%DestDir%">NUL ) rd "%%A" )