Created
October 30, 2019 22:29
-
-
Save camilonova/ec7c6ce61dbb80818493e6c976b40158 to your computer and use it in GitHub Desktop.
This script creates web files in the current directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# converting JPEG images | |
find . -type f -and \( -iname "*.jpg" -o -iname "*.jpeg" \) -exec bash -c ' | |
for result; do | |
webp_path=$(sed '\''s/\.[^.]*$/.webp/'\'' <<< "$result"); | |
if [ ! -f "$webp_path" ]; then | |
cwebp "$result" -o "$webp_path"; | |
fi; | |
done | |
' _ {} + | |
# converting PNG images | |
find . -type f -and -iname "*.png" -exec bash -c ' | |
for result; do | |
webp_path=$(sed '\''s/\.[^.]*$/.webp/'\'' <<< "$result"); | |
if [ ! -f "$webp_path" ]; then | |
cwebp -lossless "$result" -o "$webp_path"; | |
fi; | |
done | |
' _ {} + | |
# converting GIF | |
find . -type f -and -iname "*.gif" -exec bash -c ' | |
for result; do | |
webp_path=$(sed '\''s/\.[^.]*$/.webp/'\'' <<< "$result"); | |
if [ ! -f "$webp_path" ]; then | |
gif2webp "$result" -mixed -o "$webp_path"; | |
fi; | |
done | |
' _ {} + |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment