convert_img.cmd 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. @echo off
  2. chcp 65001
  3. ::cls
  4. ::color A
  5. setlocal EnableExtensions
  6. setlocal ENABLEDELAYEDEXPANSION
  7. set SRCPATH=%~1
  8. if not defined SRCPATH call :PRINT_USAGE
  9. set DESTPATH=%~2
  10. if not defined DESTPATH call :PRINT_USAGE
  11. set TMPPATH=%~3
  12. if not defined TMPPATH set TMPPATH=%TMP%
  13. set PROCS="%~dp0procs.cmd"
  14. if not exist "%SRCPATH%" call %PROCS% DIR_ERROR
  15. if not exist "%DESTPATH%" ( md "%DESTPATH%" || exit /b )
  16. if not exist "%TMPPATH%" ( md "%TMPPATH%" || exit /b )
  17. if /i "%SRCPATH%" equ "%DESTPATH%" call %PROCS% ERROR_SELF
  18. set TEMPFILENAME="%TMPPATH%\_.bpg"
  19. :: Main cycle
  20. ::if exist %TMPPATH%\Failed.txt ( del /q /s %TMPPATH%\Failed.txt 2>NUL )
  21. ::call %PROCS% PROCDIR "%SRCPATH%" "\.*.zip$ \.*.rar$" "call :EXTRACT_FILE ^"%%%%~I^" "%DESTPATH%" "%%%%SRCPATH%%%%""
  22. call %PROCS% PROCDIR "%SRCPATH%" "\.*.jpg$ \.*.png$" "call :ENCODE_FILE ^"%%%%~I^" ^"%DESTPATH%/%%%%~nI.webp^" %TEMPFILENAME%"
  23. ::call %PROCS% PROCDIR "%DESTPATH%" "\.*.bpg$" "if exist "^%%%%~dpnI.jpg^" del /q /s ^"%%%%~dpnI.jpg^" & if exist "^%%%%~dpnI.png^" del /q /s ^"%%%%~dpnI.png^""
  24. if exist "%TEMPFILENAME%" ( del /q /s "%TEMPFILENAME%" 2>NUL )
  25. ::type %TMPPATH%\Failed.txt 2>NUL
  26. echo.&pause&goto:eof
  27. :PRINT_USAGE
  28. echo:
  29. echo USAGE:
  30. echo %~n0 ^<source^> ^<destination^> [temp_dir]
  31. exit /b !ERRORLEVEL!