Skip to content

Instantly share code, notes, and snippets.

@dericed
Created September 10, 2015 16:45
Show Gist options
  • Save dericed/02b4115ab159f7e4670f to your computer and use it in GitHub Desktop.
Save dericed/02b4115ab159f7e4670f to your computer and use it in GitHub Desktop.
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