Skip to content

Instantly share code, notes, and snippets.

@PauloLuan
Last active February 27, 2024 18:59
Show Gist options
  • Save PauloLuan/5f32d8509e4b0b84074b6e168eeffd00 to your computer and use it in GitHub Desktop.
Save PauloLuan/5f32d8509e4b0b84074b6e168eeffd00 to your computer and use it in GitHub Desktop.
png_to_webp.sh
#!/bin/bash
# Loop through all PNG files in the current directory
for png_file in *.png; do
if [ -f "$png_file" ]; then
# Get the filename without the extension
filename=$(basename -- "$png_file")
filename_noext="${filename%.*}"
# Convert the PNG to WebP
cwebp "$png_file" -o "${filename_noext}.webp" -quiet
echo "Converted $png_file to ${filename_noext}.webp"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment