-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconvert.sh
37 lines (26 loc) · 847 Bytes
/
convert.sh
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
# PARAMS=('-m 6 -q 70 -mt -af -progress')
# if [ $# -ne 0 ]; then
# PARAMS=$@;
# fi
# cd $(pwd)
# shopt -s nullglob nocaseglob extglob
# for FILE in *.@(jpg|jpeg|tif|tiff|png); do
# cwebp $PARAMS "$FILE" -o "${FILE%.*}".webp;
# rm $FILE;
# done
#!/bin/zsh
# Define the image types to search for
image_types=("*.jpeg" "*.jpg" "*.tiff" "*.tif" "*.png")
# Iterate over each image type
for type in "${image_types[@]}"; do
# Find files of the specified image type
find . -type f -iname "$type" | while read -r IMAGE; do
# Get the filename without extension
filename_without_extension=${IMAGE%.*}
# Convert the image to WebP format
cwebp "$IMAGE" -o "${filename_without_extension}.webp"
echo "Converted $IMAGE to ${filename_without_extension}.webp"
rm "$IMAGE";
done
done
echo "Conversion complete."