Skip to content

Instantly share code, notes, and snippets.

@Grauwolf
Created March 24, 2016 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Grauwolf/7c3a7b60a30923d64917 to your computer and use it in GitHub Desktop.
Save Grauwolf/7c3a7b60a30923d64917 to your computer and use it in GitHub Desktop.
convert PSD files in directory to TIFF files
#!/bin/bash
# psd2tiff - convert PSD files in directory to TIFF files
set -euo pipefail
input_dir=""
output_dir=""
show_help() {
cat << EOF
Usage: ${0##*/} [-h] [-i INDIR] [-o OUTDIR]
-h display this help and exit
-i INDIR directory with PSD files
-o OUTDIR write the result files to OUTDIR
EOF
}
while getopts "h:i:o:" opt
do
case "$opt" in
h)
show_help
exit 0
;;
i)
input_dir="$OPTARG"
;;
o)
output_dir="$OPTARG"
;;
\?)
echo "Invalid option: ${OPTARG}" >&2
show_help >&2
exit 1
;;
esac
done
shift "$((OPTIND-1))"
if [ ! -z "$input_dir" ] && [ ! -z "$output_dir" ]
then
find "$input_dir" -type f -iname "*.psd" -print0 \
| parallel -0 -j4 convert "{}" -flatten -profile ColorMatchRGB.icc "${output_dir}/{/.}.tiff"
echo "Done!"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment