Added script to rename photos.

This commit is contained in:
Christian P. MOMON 2022-07-07 23:09:06 +02:00
parent fe2343d4d5
commit 67b46c99c0
1 changed files with 41 additions and 0 deletions

41
Convention photos/tphoto Executable file
View File

@ -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