Skip to content

Instantly share code, notes, and snippets.

@dericed dericed/sips-r.sh
Created Sep 10, 2015

Embed
What would you like to do?
recursive use of sips to create a directory of thumbnails from a directory of images
#!/bin/bash
if [[ ! "${#}" == 2 ]] ; then
echo "Please provide input and output directories, and no other arguments."
exit 1
fi
input="${1}"
output="${2}"
find "${input}" -type f | \
while read file ; do
echo "processing ${file} a $input b $output"
outname=$(echo "${file}" | sed 's|'"${input}"'|'"${output}"'|g')
echo out $outname
outdir=$(dirname "${outname}")
if [[ ! -d "${outdir}" ]] ; then
mkdir -p "${outdir}"
fi
sips -s format jpeg -Z 150 "${file}" --out "${outname}_thumb.jpg"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.