Skip to content

Instantly share code, notes, and snippets.

@axolx
Created March 23, 2011 19:24
Show Gist options
  • Save axolx/883762 to your computer and use it in GitHub Desktop.
Save axolx/883762 to your computer and use it in GitHub Desktop.
Convert all PSD files in a directory to JPG
#! /bin/sh
#############################################
# Convert all PSD files in a directory to JPG
#
# Author: Martin Rio
# Version: 0.1 (3/23/2011)
# Dependencies:
# - ImageMagick's convert utility
#############################################
CONVERT=/opt/local/bin/convert
if [ $# != 1 ]; then
usage
exit 1;
fi
if [ ! -d $1 ]; then
echo "Could not read directory $1"
usage
exit 1;
fi
if [ ! -d $1/jpg ]; then
mkdir $1/jpg
echo "Created $1/jpg"
fi
(
IFS=$'\n'
for path in `find $1 -name '*.psd'`
do
psd=`basename $path`
name=`basename -s .psd $path`
echo "Converting $psd"
$CONVERT $path[0] $1/jpg/$name.jpg
done
)
exit 0
usage()
{
echo "Usage: psdtojpeg.sh [directory name]"
}
@axolx
Copy link
Author

axolx commented Mar 23, 2011

Feedback welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment