cleanscan.cmd 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. @echo off
  2. chcp 65001
  3. setlocal enableextensions enabledelayedexpansion
  4. set "SRCPATH=%~1"
  5. if not defined SRCPATH set "SRCPATH=%~dp0"
  6. set "DESTPATH=%~2"
  7. if not defined DESTPATH set "DESTPATH=%~dp0/out"
  8. if not exist "%DESTPATH%" mkdir "%DESTPATH%"
  9. set "FILEMASKS=%~3"
  10. if not defined FILEMASKS set "FILEMASKS=\.*.png$"
  11. set "TMPPATH=%Temp%"
  12. if not exist "%SRCPATH%\*" call PRINT_USAGE
  13. if not exist "%DESTPATH%\*" ( md "%DESTPATH%" || exit /b )
  14. if not exist "%TMPPATH%\*" ( md "%TMPPATH%" || exit /b )
  15. for /f "usebackq tokens=* delims=" %%I in ( `dir /b /a:-d "%SRCPATH%\*" 2^>NUL ^| findstr /i "%FILEMASKS%" 2^>NUL` ) do (
  16. set FN=%%~nxI
  17. @echo.Processing file !FN:\=\\!
  18. gm convert -colorspace gray -level "25%%,10,26%%" -convolve "0,0,0,0,0,0,1,1,1,0,1,1,14,1,1,0,1,1,1,0,0,0,0,0,0" -median 3 -level "99%%,10,99%%" "!SRCPATH!/!FN!" "!TMPPATH!/test.png"
  19. gm composite -compose bumpmap -negate "!SRCPATH!/!FN!" -negate "!TMPPATH!\test.png" "%DESTPATH%\!FN:\=\\!"
  20. gm convert -negate -level "0%%,1,58%%" "%DESTPATH%\!FN:\=\\!" "%DESTPATH%\!FN:\=\\!"
  21. )
  22. echo.Ready.
  23. echo.&pause&goto:eof
  24. :PRINT_USAGE
  25. echo:
  26. echo USAGE:
  27. echo %~n0 ^<source^> ^<destination^> [filemask]
  28. exit /b !ERRORLEVEL!