Advertisement
stempy

Batch .webp TO .png Converter using dwebp

Jul 27th, 2019
995
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2. SETLOCAL
  3. echo =====================================================
  4. echo Convert .WEBP files to .PNG using Googles dwebp
  5. echo =====================================================
  6. echo.
  7. set dwebpurl=https://developers.google.com/speed/webp/docs/precompiled
  8. where dwebp /Q
  9. if "%errorlevel%" NEQ "0" echo dwebp.exe NOT FOUND --- download from %dwebpurl% & exit /b 2
  10.  
  11.  
  12. for /d %%d in (*) do call :cnv "%%d"
  13. goto :end
  14.  
  15. :cnv
  16. rem Convert
  17. rem ==============================================
  18. SETLOCAL
  19. set dirPath=%~1
  20. echo Processing folder "%dirPath%"........
  21. if NOT exist "%dirPath%\*.webp" exit /b 0
  22. pushd "%dirPath%"
  23. REM ---- convert ONLY if no .png version exists ------
  24. for %%a in (*.webp) do IF NOT EXIST "%%~na.png" dwebp %%a -o %%~na.png
  25. popd
  26. echo Processed "%dirPath%" completed!!!
  27. ENDLOCAL
  28. exit /b %errorlevel%
  29.  
  30.  
  31.  
  32. :end
  33. pause
  34. ENDLOCAL
  35. echo.
  36. echo Conversion Completed!!
  37. echo.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement