generate webp images only if they don’t exist

find /path/to/dir -regextype posix-egrep -regex ".*\.(png|jpeg|jpg)$" -type f -print0 | xargs -0 -I {} bash -c 'if [ ! -f "${1%.*}.webp" ]; then cwebp -m 6 -q 70 "$1" -o "${1%.*}.webp"; fi' -- {}
 

perform gzip and brotli compression on all supported files in a directory

find . -regextype posix-egrep -regex ".*\.(py|html|js|css|xml|svg|tff|woff|woff2|glb)$" -type f -print0 | xargs -0 brotli -q 11
find . -regextype posix-egrep -regex ".*\.(py|html|js|css|xml|svg|tff|woff|woff2|glb)$" -type f -print0 | xargs -0 gzip -k -9