diff --git a/Convention photos/tphoto b/Convention photos/tphoto new file mode 100755 index 0000000..2caa503 --- /dev/null +++ b/Convention photos/tphoto @@ -0,0 +1,41 @@ +#!/bin/bash + +function checkJhead() +{ + local result + local check=$(which ant) + if [[ "$check" =~ ^/.* ]]; then + echo "jhead requirement OK" + result=1 + else + echo "jhead requirement MISSING" + result=0 + fi + return $result +} + +# main + +# Lowercase extension. +uppercaseCount=$(find -maxdepth 1 -name '*.JPG' | wc -l) +if [[ $uppercaseCount > 0 ]]; then + rename 's/JPG/jpg/' *.JPG +fi +echo ".JPG -> .jpg: $uppercaseCount" + +# Rename. +checkJhead +if [[ $? == 1 ]]; then + count=0 + for filename in $(ls *.jpg); do + #echo "==== $filename" + if [[ $(jhead $filename | grep Date) =~ ^Date.* ]]; then + #echo "yop $filename" + jhead -n%Y%m%d-%H%M%S "$filename" + let "count+=1" + fi + done + echo "Renamed: $count" +else + echo "KO" +fi