Guest User

Untitled

a guest
Jun 24th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SETLOCAL EnableDelayedExpansion
  2. @echo off
  3.  
  4. :: Should have no slashes on the end and do not wrap with double quotes!
  5. SET SourceDir=C:\Users\Bangonkali\Desktop\Barangay
  6. SET DestDir=C:\Users\Bangonkali\Desktop\Barangay\Group
  7. SET MaxPerDir=100
  8.  
  9. IF NOT EXIST "%DestDir%" mkdir "%DestDir%"
  10.  
  11. SET Bucket=0
  12. SET Item=0
  13. SET Count=0
  14.  
  15. FOR /R "%SourceDir%" %%G IN (*.*) DO (
  16.     Pushd %%G
  17.     ECHO !Count!: Now Checking "%%G"
  18.     IF NOT EXIST "%DestDir%\FOLDER!Bucket!" (
  19.         ECHO Creating directory "%DestDir%\FOLDER!Bucket!"...
  20.         mkdir "%DestDir%\FOLDER!Bucket!"
  21.     )
  22.    
  23.     ECHO Copying file "%%G" to destination...
  24.     xcopy "%%G" "%DestDir%\FOLDER!Bucket!"
  25.     :: echo %%G %DestDir%\FOLDER!Bucket!
  26.     Popd
  27.    
  28.     SET /A Count=!Count!+1
  29.     SET /A Item=!Item!+1
  30.     IF !Item!==!MaxPerDir! (
  31.         SET Item=0
  32.         SET /A Bucket=!Bucket!+1
  33.     )
  34. )
  35. SET Item=0
  36. SET Count=0
  37. SET Bucket=0
  38. SET SourceDir=
  39. SET DestDir=
  40. SET MaxPerDir=
  41.  
  42. ECHO Operation Completed
Add Comment
Please, Sign In to add comment