Skip to content

Auto date photos

Pablo Casas Estévez edited this page Jan 30, 2021 · 11 revisions

Auto-date Photos.

The routine selects images and videos with no exposure time and tries to find a date from the file name and paths, the date of the file creation, or finally a date from the event it is assigned (if any).

Once a date is found, it assigns the date at the database, and tries to add the image to an existent event (if it hasn't got already one).

Trashed files are omitted.

How retrieves the date:

  • It searches for valid years on the Path: ../2016/.... It will get 2016 as year. (You can define a minimum valid year for more date-accurate)
  • It searches for a valid month on the Path: .../2016/03/... It will get march as month.
  • It searches for a valid day on the Path: .../2016/03/05/... It will get 5th as day.
  • It searches for a year and month on the Path .../2016-03/.... It will get this year and month. (also with other separators [- _ / : .] even joined.
  • It searches for a sequence of Year-month-day on the Path , works by the same way.
  • The same thing using the filename. .../2016-05-03 the great beer party.jpg retrieves the date.
  • Finally it searches for a full-date identifier on the filename: ../2016-05-03 20:30:22 the great beer party.jpg retrieves the date and the time. (also with other characters [- _ / : .] as separator and even joined.
  • If assignstat = True it assigns the date of creation of the file at the filesystem (be careful with this option. Usually you want this option to True if you already have all the images dated at your library)

Defaults:

If no day is found, 01 is assigned.
If no hour is found, 12pm is assigned.
If no minutes is found, 00 minutes is assigned.
If no seconds is found, 00 seconds is assigned.
So a year and a month has to be found in order to assign something.

How to assign the images to an existent event:

If the image is not yet into an event. (Simply it is at the No dated virtual folder)
The script searches for an unique event which contains images in the gap of +- 4hours. In case an unique event is found, images will be added to it. In other case, a new event will be created for the image.

If the image is already into an existent event and it could not be dated: it retrieves the Minimun date of the event that pertains, and it is assigned as its date.

If the image is already into an existent event and it could be dated by itself: the image keeps its event and is dated with the found date.

Insert found date as metadata into the image:

The found date is inserted as metadata into the image (EXIF) if you have this option active in Shotwell's preferences.(only works for .jpg files)

Months on other languages:

You can set your own words for the months, just hack the code and add new words following the structure.
You can also send me your added words to update the base code.

monthsdict = {
"01" : ("enero", "ene", "juanuary", "jan"),
"02" : ("febrero", "feb", "february"),
"03" : ("marzo", "mar", "march"),
"04" : ("abril", "abr", "april", "apr"),
"05" : ("mayo", "may","may"),
"06" : ("junio", "jun", "june"),
"07" : ("julio", "jul", "july"),
"08" : ("agosto", "ago", "agost"),
"09" : ("septiembre", "sep", "set","september"),
"10" : ("octubre", "oct", "october"),
"11" : ("noviembre", "nov", "november"),
"12" : ("diciembre", "dic", "december", "dec"),
} # Months word dict.