-
Notifications
You must be signed in to change notification settings - Fork 0
/
img_to_webp.bat
69 lines (63 loc) · 1.5 KB
/
img_to_webp.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
@echo off
title IMG to WEBP
setlocal enabledelayedexpansion
:: ---------- START ----------
:start
cls
echo.
color f
echo Hi there, welcome to Bulk File Renamer
echo by Github: @curlynoemi
echo.
echo ---------------------------------------------------------
echo.
:: ---------- CHECK IF CWEB IS INSTALLED ----------
where cwebp >nul 2>nul
if %errorlevel% neq 0 (
goto nowebp
)
:: ---------- CONVERSION ----------
echo Enter the folder path of the files you want to convert.
echo It must include ONLY the files you want to convert.
echo.
set /p "folderPath= "
set /p "allProceed=Can I proceed? (y/n): "
if /i "%allProceed%"=="y" (
cls
echo.
for %%i in ("%folderPath%\*.jpg" "%folderPath%\*.jpeg" "%folderPath%\*.png") do (
if exist "%%i" (
set "fileName=%%~nxi"
echo Converting !fileName! to WebP...
cwebp "%%i" -q 100 -o "!folderPath!\!fileName:.=!_webp"
cls
echo.
)
)
goto :success
) else (goto error)
:: ---------- NO WEBP INSTALLED ----------
:nowebp
cls
echo.
color 4
echo Seems like you haven't installed cwebp.
echo https://github.com/curlynoemi/batch_tools?tab=readme-ov-file#-bulk-image-to-webp-converter
pause >nul
goto start
:: ---------- SUCCESS ----------
:success
cls
echo.
color 2
echo All done!
pause >nul
goto start
:: ---------- ERROR ----------
:error
cls
echo
color 4
echo Oops. Something went wrong, try again.
pause >nul
goto start