Created
December 10, 2022 00:15
-
-
Save Alexander01998/6f13d14858eac7eda137d465279b7899 to your computer and use it in GitHub Desktop.
A batch script that converts all .jpg images in a folder to .webp at 100% quality. Just place it in the folder and double-click. Only works if you have cwebp installed: https://developers.google.com/speed/webp/docs/precompiled
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
rem Set the number of files to be converted | |
for /f "delims=" %%i in ('dir /b /a-d /s *.jpg ^| find /c /v ""') do set "numFiles=%%i" | |
echo Converting %numFiles% file(s)... | |
rem Convert each .jpg file in the current directory to .webp | |
setlocal enabledelayedexpansion | |
set cnt=0 | |
for /f "delims=" %%i in ('dir /b /a-d /s *.jpg') do ( | |
cwebp -quiet -q 100 "%%i" -o "%%~dpni.webp" | |
set /a cnt+=1 | |
set progress=!cnt! | |
set /a progress=!progress! * 100 / %numFiles% | |
echo !progress!%% converted | |
) | |
endlocal | |
echo Done! | |
pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment