home/.config/fish/scripts/toavif
2025-06-26 13:37:26 +02:00

36 lines
No EOL
625 B
Fish
Executable file

#!/usr/bin/fish
if not set -q argv[1]
echo "Usage: $argv[0] /path/to/search"
exit 1
end
for jpg in (find $argv[1] -type f -name '*.jpg')
set avif (string replace -r '\.jpg$' '.avif' $jpg)
if test -f $avif
echo Skip $avif
continue
end
echo Converting $jpg to $avif
avifenc $jpg $avif
set json "$jpg.JSON"
if test -f $json
echo Renaming JSON $json to "$avif.JSON"
mv $json "$avif.JSON"
end
end
for png in (find $argv[1] -type f -name '*.png')
set avif (string replace -r '\.png$' '.avif' $png)
if test -f $avif
echo Skip $avif
continue
end
echo Converting $png to $avif
avifenc $png $avif
end