Created
March 23, 2011 19:24
-
-
Save axolx/883762 to your computer and use it in GitHub Desktop.
Convert all PSD files in a directory to JPG
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/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]" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Feedback welcome!