mod_files.bat 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. @ECHO OFF
  2. SETLOCAL ENABLEDELAYEDEXPANSION
  3. IF _%1_==_AUTO_ (
  4. GOTO MakeDirs
  5. )
  6. IF _%2_==__ (
  7. ECHO Usage %0 ^<basedir^> ^<depth^> ^[^hash_bits^]
  8. ECHO.
  9. ECHO Where ^<basedir^> is the session directory
  10. ECHO ^<depth^> is the number of levels defined in session.save_path
  11. ECHO ^[hash_bits^] is the number of bits defined in session.hash_bits_per_character
  12. EXIT /B 1
  13. )
  14. SET /A Depth=%2 + 0 2>NUL
  15. IF /I %ERRORLEVEL% EQU 9167 GOTO DepthError
  16. IF _%Depth%_==__ GOTO DepthError
  17. IF /I %Depth% LEQ 0 GOTO DepthError
  18. IF _%3_==__ GOTO DefaultBits
  19. SET /A Bits=%3 + 0 2>NUL
  20. IF /I %ERRORLEVEL% EQU 9167 GOTO BitsError
  21. IF _%Bits%_==__ GOTO BitsError
  22. IF /I %Bits% LSS 4 GOTO BitsError
  23. IF /I %Bits% GTR 6 GOTO BitsError
  24. GOTO BitsSet
  25. :DefaultBits
  26. SET Bits=4
  27. :BitsSet
  28. SET HashChars=0 1 2 3 4 5 6 7 8 9 A B C D E F
  29. IF /I %Bits% GEQ 5 SET HashChars=!HashChars! G H I J K L M N O P Q R S T U V
  30. IF /I %Bits% GEQ 6 SET HashChars=!HashChars! W X Y Z - ,
  31. FOR %%A IN (%HashChars%) DO (
  32. ECHO Making %%A
  33. CALL "%~0" AUTO "%~1\%%~A" %Depth%
  34. )
  35. GOTO :EOF
  36. :MakeDirs
  37. MKDIR "%~2"
  38. SET /A ThisDepth=%3 - 1
  39. IF /I %ThisDepth% GTR 0 FOR %%A IN (%HashChars%) DO CALL "%~0" AUTO "%~2\%%~A" %ThisDepth%
  40. GOTO :EOF
  41. :DepthError
  42. ECHO ERROR: Invalid depth : %2
  43. EXIT /B 0
  44. :BitsError
  45. ECHO ERROR: Invalid hash_bits : %3
  46. EXIT /B 0