Skip to content

Instantly share code, notes, and snippets.

@yene
Created October 9, 2019 17:18
Show Gist options
  • Save yene/cb4f7f7b2b0be42c974694a58d0cae97 to your computer and use it in GitHub Desktop.
Save yene/cb4f7f7b2b0be42c974694a58d0cae97 to your computer and use it in GitHub Desktop.
Automator convert images to webp, keep mod and creation date
# automator Passes images in as argument
for f in "$@"
do
dc="$(GetFileInfo -d "$f")" # store creation date
dm="$(GetFileInfo -m "$f")" # store modification date
noExt=${f%.*}
# needs to be installed with brew install webp
newExt="$noExt".webp
/usr/local/bin/cwebp -q 90 "$f" -o "$newExt"
SetFile -d "$dc" "$newExt" # restore creation date
SetFile -m "$dm" "$newExt" # restore modification date
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment