Skip to content

Instantly share code, notes, and snippets.

View toddfraser's full-sized avatar

Todd Fraser toddfraser

View GitHub Profile
@toddfraser
toddfraser / move-all-webp.sh
Created October 7, 2025 15:31
Move all .webp files into their own folder (recursively)
#!/usr/bin/env bash
# Collect .webp files recursively
FILES=()
while IFS= read -r -d '' FILE; do
FILES+=("$FILE")
done < <(find . -type f -iname "*.webp" -print0)
TOTAL=${#FILES[@]}
COUNT=0
@toddfraser
toddfraser / folder-convert-webp.sh
Created October 7, 2025 15:15
Convert folder of images to WEBP (max 2000px width)
#!/usr/bin/env bash
# Default cwebp params. Override by passing your own flags to the script.
PARAMS=( -m 6 -q 80 -resize 2000 0 -mt -af -progress )
if [ "$#" -ne 0 ]; then
PARAMS=( "$@" )
fi
# Find images under the current folder, case-insensitive, safely handle spaces and odd chars.
# For each file, write output next to the source with the same base name and .webp extension.