Detecting many different DateTime patterns

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Hi,

As the years progress i've been asked/requested by friends/family & other fools to help them cleanup their chaotic Photo galleries. Think a typical combination of Media in Photos Library, Google Photo's synced, Dropbox, Flickr, iPhone, Android syncs, Digitized Photo's (yep. those with dateTaken before 1/1/1970) and Whatsapp stuff..
In the meantime i've become pretty good/fast in cleanup the rubble by using a combination of self-written shell scripts, Gemini 2, A Better Finder Renamer, Finder and recently i've added Hazel to the mix.
Although Hazel is not the 'fastest' way to bulk progress 10 to 100,000's of precious home photo's & video's, it allows me to reduce the number of manual steps drastically and allows me to have a more "robust" workflow.


My flow
Once i have a DateTimeOriginal stored in the image/video metadata, the following re-organisation is applied.
Image

My problem
For media that does NOT have DateTime data stored in metadata, i'm forced to switch to manual mode and use custom shell scripts and tools mentioned above to handle all different cases in which i'm still able to detect a DateTime pattern on sight. eg.
[*]it's in the filename YYYY-MM-DD_hh:mm:ss-some very funnyname.jpg
[*]or YYYYMMDD_hh.mm-someothername.JPEG
[*]or YYMMDD_NoTimeFound.JPEG
[*]or It's in the parent folder name "May 20th 2017, Birthday of some child"
[*]or even better "20th anniversary of some marriage"
[*]...

BTW I also Store the original filename into the METADATA just to be sure I can always revert in case the automation messed up.

My question
What would be the best approach to setup Rules & Actions & maybe some shell script magic to automate the detection of DateTime and save it into the DateTimeOriginal of metadata.
Basically, i could create new rules for any different kind of DateTime situation I match, and execute almost similar exiftool script to handle that situation, but I'm hoping there are more generic ways to handle the situation.
roel.de.meester
 
Posts: 1
Joined: Thu Nov 02, 2017 2:05 pm

You can use "any" with multiple conditions for each case underneath. That way you can consolidate this into one rule. In addition, you can try using automatic date detection when creating a custom date attribute which should cover many of the straightforward cases.
Mr_Noodle
Site Admin
 
Posts: 11236
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Detecting many different DateTime patterns Fri Feb 09, 2018 10:06 pm • by apolaine
I have a similar question, so I'd be interested to know if you've worked it out. I currently use this script to extract and correct EXIF data:
Code: Select all
<?php

date_default_timezone_set("Australia/Sydney");

$date = exif_read_data($argv[1],"EXIF");

$date = $date["DateTimeOriginal"];

$time = date_parse_from_format("Y:m:d H:i:s",$date);

$time = mktime($time["hour"],$time["minute"],$time["second"],$time["month"],$time["day"],$time["year"]);

touch($argv[1],$time,$time);

?>


Then sort my photos into days, months and years. The problem is, WhatsApp and other social media images have their EXIF data scrubbed. They end up in random 1999 folders as a result. I'd like to have some kind of cascading rule that tries to sort by EXIF data and, if it fails, simply resorts to file creation date on my machine, which at least gets me close to the right date if I save regularly.

Any suggestions?
apolaine
 
Posts: 2
Joined: Fri Feb 09, 2018 10:02 pm

Again, you can use "any" with multiple conditions. Depending, you can check whether a date is blank or some default value or not.
Mr_Noodle
Site Admin
 
Posts: 11236
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:Again, you can use "any" with multiple conditions. Depending, you can check whether a date is blank or some default value or not.


Thanks Mr Noodle, but I don't quite understand how the logic of that works. The way I have the condition set up is to check whether it's an image or not (I have another rule for videos) in the folder. The date extraction is done in the embedded script, then the other "do" rules rename and sort. Do I need multiple rules to the kind of if...then construction you've outline above? I can see it working in one rule.
apolaine
 
Posts: 2
Joined: Fri Feb 09, 2018 10:02 pm

If you use an AppleScript, you can have it return multiple values back to Hazel so that they can be used in subsequent conditions. Not sure how feasible that is in your case but it's something to consider.
Mr_Noodle
Site Admin
 
Posts: 11236
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support

cron