Windows batch - move x amount of folders+content to another folder -
i in process of cleaning , organizing nas folders.
however, have folder on 1800+ folder in it, need have split 18 folders each containing maximum 100 folders. name of folder moved irrelevant, @ top-level should sequential. folder content should moved along.
additionally, need batch file reverses this.
the reason needed due program uses index , organize folders , folder content cannot handle folders more 100 folders.
i tried myself already, ended foobar'ing completely.
something this?
@echo off set destination=c:\temp\ set source=c:\windows\system32\ set dcount=0 set fcount=0 setlocal enabledelayedexpansion mkdir %destination%dir%dcount% /f "tokens=*" %%f in ('dir /b /s /a:d "%source%*"') ( set str=%%f set str=!str:%source%=! mkdir %destination%dir!dcount!\!str! copy %%f %destination%dir!dcount!\!str! 1> nul set /a fcount=!fcount!+1 if !fcount! equ 100 ( set fcount=0 set /a dcount=!dcount!+1 mkdir %destination%dir!dcount! ) ) echo done.
obviously source , destination need changed, , there no attempt sanity check or fail gracefully errors...
edit :
the first version recursively descends sub-directories , moves each them new structure--basically destroying internal nesting , organization. second 1 preserves internal structures of subdirectories nested inside of source directory's immediate subdirectories... take pick.
@echo off set destination=c:\temp\ set source=c:\windows\system32\ set dcount=0 set fcount=0 setlocal enabledelayedexpansion mkdir %destination%dir%dcount% /f "tokens=*" %%f in ('dir /b /a:d "%source%*"') ( mkdir %destination%dir!dcount!\%%f xcopy %source%%%f %destination%dir!dcount!\%%f /e /y set /a fcount=!fcount!+1 if !fcount! equ 100 ( set fcount=0 set /a dcount=!dcount!+1 mkdir %destination%dir!dcount! ) ) echo done.
Comments
Post a Comment