Advertisement
Guest User

batch convert all .webp files to png

a guest
Jul 27th, 2019
155
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 rob@stempnet.com
  6. echo =====================================================
  7. echo.
  8. set dwebpurl=https://developers.google.com/speed/webp/docs/precompiled
  9. where dwebp /Q
  10. if "%errorlevel%" NEQ "0" echo dwebp.exe NOT FOUND --- download from %dwebpurl% & exit /b 2
  11.  
  12.  
  13. for /d %%d in (*) do call :cnv "%%d"
  14. goto :end
  15.  
  16. :cnv
  17. rem Convert
  18. rem ==============================================
  19. SETLOCAL
  20. set dirPath=%~1
  21. echo Processing folder "%dirPath%"........
  22. if NOT exist "%dirPath%\*.webp" exit /b 0
  23. pushd "%dirPath%"
  24. REM ---- convert ONLY if no .png version exists ------
  25. for %%a in (*.webp) do IF NOT EXIST "%%~na.png" dwebp %%a -o %%~na.png
  26. popd
  27. echo Processed "%dirPath%" completed!!!
  28. ENDLOCAL
  29. exit /b %errorlevel%
  30.  
  31.  
  32.  
  33. :end
  34. pause
  35. ENDLOCAL
  36. echo.
  37. echo Conversion Completed!!
  38. echo.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement