#!/usr/bin/env sh

# rename .JPG -> .jpg
count=`ls -1 *.JPG 2>/dev/null | wc -l`
if [ $count != 0 ]; then
  rename JPG jpg *.JPG
fi
  
# remove exif except orientation from .jpg
count=`ls -1 *.jpg 2>/dev/null | wc -l`
if [ $count != 0 ]; then
  for i in *.jpg; do
    exiftool -all= -overwrite_original -tagsfromfile @ -Orientation "$i"
  done
fi

# rename .PNG -> .png
count=`ls -1 *.PNG 2>/dev/null | wc -l`
if [ $count != 0 ]; then 
  rename PNG png *.PNG
fi
  
# remove exif except orientation from .png
count=`ls -1 *.png 2>/dev/null | wc -l`
if [ $count != 0 ]; then
  for i in *.png; do
    exiftool -all= -overwrite_original -tagsfromfile @ -Orientation "$i"
  done
fi