Improved rphoto.

This commit is contained in:
Christian P. MOMON 2022-07-19 15:53:05 +02:00
parent fa878851eb
commit 889a65a45d
1 changed files with 6 additions and 4 deletions

View File

@ -17,11 +17,10 @@ checkcommand()
help() help()
{ {
echo "Usage: tphoto [-n] [ -h | -f ] [ *.jpg ]" echo "Usage: tphoto [ -h | -f ] [ *.jpg ]"
echo "Rename jpg files using Exif Original Date/Time if exists." echo "Rename jpg files using Exif Original Date/Time if exists."
echo " -h Display help." echo " -h Display help."
echo " -f Force rename jpg files with Exif datetime or file datetime." echo " -f Force rename jpg files with Exif datetime or file datetime."
echo " -n Dry run."
} }
doRename() doRename()
@ -35,7 +34,11 @@ doRenameCarefully()
{ {
local filename=$(basename $1) local filename=$(basename $1)
#echo "$filename" #echo "$filename"
if [[ $(exiftool $filename | grep -c "Date/Time Original") > 0 ]]; then if [[ $filename =~ IMG[12][90][0-9][0-9][01][0-9][0-3][0-9][012][0-9][0-5][0-9][0-5][0-9].* ]]; then
local target=${filename:0:11}-${filename:11}
echo "$filename -r> $target"
mv -f "$filename" "$target"
elif [[ $(exiftool $filename | grep -c "Date/Time Original") > 0 ]]; then
#echo "yop $filename" #echo "yop $filename"
doRename "$filename" doRename "$filename"
else else
@ -54,7 +57,6 @@ else
fi fi
fi fi
if [[ $# == 0 ]]; then if [[ $# == 0 ]]; then
find . -maxdepth 1 -type f -iname "*.jpg" | while read path find . -maxdepth 1 -type f -iname "*.jpg" | while read path
do do