if date not found, defaults to directory date

This commit is contained in:
Danilo Reyes 2024-07-16 13:20:17 -06:00
parent acc1106f3f
commit a8a7904716
2 changed files with 6 additions and 3 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.log

View File

@ -85,8 +85,8 @@ for year_dir in "$base_dir"/*/; do
# Extract the date from the photo metadata
photo_date=$(exiftool -DateTimeOriginal -d "%Y:%m:%d %H:%M:%S" "$photo" | awk -F': ' '{print $2}')
if [ -z "$photo_date" ]; then
# Scenario 2: No date metadata
if [ -z "$photo_date" ] || [[ "$photo_date" == "0000:00:00 00:00:00" ]] || [[ "$photo_date" == "1970:01:01 00:00:00" ]] || [[ "$photo_date" == "1979:12:31 21:00:00" ]]; then
# Scenario 2: No date metadata or invalid date
filename_datetime=$(extract_datetime_from_filename "$photo")
if [ -n "$filename_datetime" ]; then
@ -130,10 +130,12 @@ for year_dir in "$base_dir"/*/; do
echo " Suggested action: Update photo metadata to match filename date."
fi
else
new_date="$year:$month:01 00:00:00"
log_change "$photo" "$photo_date" "$new_date"
echo "Mismatch found: $photo"
echo " Directory date: $year/$month"
echo " Photo date: $photo_date"
echo " No valid date found in filename."
echo " No valid date found in filename. Defaulting to directory date."
fi
fi
fi