Created
September 10, 2015 16:45
-
-
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
This file contains 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 | |
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