Data from filename or filesystem for image metadata

Does Retrobatch allow pulling something like date information from the filename or filesystem metadata, to use as data that can be inserted into the image’s EXIF metadata?

Example: I have a lot of older JPEG photos that have (almost) nothing in the way of EXIF metadata. The filenames, however, contain YYYY-MM-DD data. I’d like to extract that from the name and insert it into the EXIF as image date — preferably without any recompression. In some of these files, the filesystem creation/modification date(s) may also be useful if they can be extracted for re-use.

This is something that could be done with a JavaScript plugin.

The trick is going to be pulling out the date from file name. Do the file names start with the date, or is it kind of fuzzy?

The filename is basically the date, plus an incrementing number. So …

1999-04-15-001.jpg
1999-04-15-002.jpg
1999-04-15-003.jpg

… and so on.

If this requires JavaScript (or any scripting), it seems like that’s a Pro-only feature.

Yea, the plugins are for Pro only.

I’ve put together a quick example here: https://flyingmeat.com/retrobatch/jsplugin/

“Fuzzy Date Set” is the name. It’ll parse the dates out in the format “YYYY-MM-DD extra stuff here”. If you want to adopt it for your case with the incrementing numbers, that’ll require a little bit of modification (maybe add a split based on the character ‘-’).

Found a nice bit of javascript to find the ISO date within a string without requiring it to be separated by a space.

Works with:
2014-09-04-09.53.25.jpg
IMG00124-20110111-1650.jpg

Looks cool, and maybe I can adopt it when I get a chance, but I’m pretty sure that’s not JavaScript and might possibly be powershell script.

How silly of me! You’re right, of course.

How about some actual javascript. Replace lines 15 and 16 in your MainScript.js with the following:

// Assumes dates are year 1500 thru 2400
// Matches first date found in the form of 2014-09-04 or 20140904; leading zeros required.
const ISODateRegex = /(?:1[5-9]|2[0-4])\d{2}-?[01]\d-?[0-3]\d/;
var theDate = theFileName.match(ISODateRegex);

That should do it!

Not quite- it’s failing in my testing (never played with JS regex), but I’ll take a stab at figuring out why later on.