Last active
March 24, 2021 16:54
-
-
Save codingChewie/5769bc254264765add4378f63cc3c79d to your computer and use it in GitHub Desktop.
Shell script that takes TIF images and converts them to JPGs
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
# Date: 16-02-09 | |
# Developer: codingChewie | |
# Purpose: Convert TIF images to JPG and move TIFs into a directory | |
# Version: 1.0 | |
# Name: tif-to-jpg.sh | |
# Site: http://programmingmonkeys.com/ | |
WORKING="" | |
TIFFOLDER="tif" | |
movebad=0 | |
for allimg in $(find "$WORKING" -name "*.tif" ); do | |
cd $WORKING | |
tifcreate=0 | |
if [[ $allimg == *.tif ]]; then | |
for tifimg in $(find "$WORKING" -name "*.tif" ); do | |
sips -s format jpeg "${tifimg}" --out "${tifimg%tif}jpg"; | |
done | |
while [ $tifcreate -eq "0" ]; do | |
if [ ! -e "$TIFFOLDER" ]; then | |
cd $WORKING | |
mkdir -p $TIFFOLDER | |
echo "Added Folder" $TIFFOLDER | |
fi | |
let tifcreate=1 | |
done | |
fi | |
movebad=1 | |
done | |
if [ $movebad -eq "1" ]; then | |
for tifbadimages in $(find "$WORKING" -name "*.tif" ); do | |
cd $WORKING | |
filename=$(basename $tifbadimages | cut -d"." -f1 ) | |
if [ -e "$filename.tif" ] && [ -e "$filename.jpg" ]; then | |
mv $tifbadimages $WORKING/$TIFFOLDER | |
fi | |
done | |
fi | |
for dspurge in $(find $WORKING -name .DS_Store); do | |
rm -v -f $dspurge | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment