diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..397b4a7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.log diff --git a/photos-metadata.sh b/photos-metadata.sh index 35c40fc..62e86e5 100755 --- a/photos-metadata.sh +++ b/photos-metadata.sh @@ -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