#!/bin/bash
uploadDir=/home/behnood/webptest/*
for file in $uploadDir
do
if [[ $file = *.jpg || $file = *.png ]]
then
if ! [[ -f "$file".webp ]]
then
# there is no .webp file for this .jpg file, let's create it!
cwebp "$file" -o "$file".webp
fi
elif [[ $file = *.webp ]]
then
if ! [[ -f "${file%.*}" ]]
then
#we have a .webp file but the original .jpg file is missing. let's delete it!
rm "$file"
fi
fi
done
I have a bash script that checks a directory and if there is no webp file for each jpg or png file, creates it using cwebp. this script runs perfectly when I call it manually, however when I schedule a cron job to, for example, run it every minute, cwebp does nothing. other commands in my bash script run without a problem, like rm. so I know this is not a permission issue. can anyone help me? what am I missing? I'm using Ubuntu 14.04.here is my script:
#!/bin/bash
uploadDir=/home/behnood/webptest/*
for file in $uploadDir
do
if [[ $file = *.jpg || $file = *.png ]]
then
if ! [[ -f "$file".webp ]]
then
# there is no .webp file for this .jpg file, let's create it!
cwebp "$file" -o "$file".webp
fi
elif [[ $file = *.webp ]]
then
if ! [[ -f "${file%.*}" ]]
then
#we have a .webp file but the original .jpg file is missing. let's delete it!
rm "$file"
fi
fi
done
--
You received this message because you are subscribed to the Google Groups "WebP Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webp-discuss...@webmproject.org.
To post to this group, send email to webp-d...@webmproject.org.
Visit this group at https://groups.google.com/a/webmproject.org/group/webp-discuss/.
For more options, visit https://groups.google.com/a/webmproject.org/d/optout.