Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SETLOCAL EnableDelayedExpansion
- @echo off
- :: Should have no slashes on the end and do not wrap with double quotes!
- SET SourceDir=C:\Users\Bangonkali\Desktop\Barangay
- SET DestDir=C:\Users\Bangonkali\Desktop\Barangay\Group
- SET MaxPerDir=100
- IF NOT EXIST "%DestDir%" mkdir "%DestDir%"
- SET Bucket=0
- SET Item=0
- SET Count=0
- FOR /R "%SourceDir%" %%G IN (*.*) DO (
- Pushd %%G
- ECHO !Count!: Now Checking "%%G"
- IF NOT EXIST "%DestDir%\FOLDER!Bucket!" (
- ECHO Creating directory "%DestDir%\FOLDER!Bucket!"...
- mkdir "%DestDir%\FOLDER!Bucket!"
- )
- ECHO Copying file "%%G" to destination...
- xcopy "%%G" "%DestDir%\FOLDER!Bucket!"
- :: echo %%G %DestDir%\FOLDER!Bucket!
- Popd
- SET /A Count=!Count!+1
- SET /A Item=!Item!+1
- IF !Item!==!MaxPerDir! (
- SET Item=0
- SET /A Bucket=!Bucket!+1
- )
- )
- SET Item=0
- SET Count=0
- SET Bucket=0
- SET SourceDir=
- SET DestDir=
- SET MaxPerDir=
- ECHO Operation Completed
Add Comment
Please, Sign In to add comment