Making a preset for photo date created (or modified)

Support for Windows 10 users and the Microsoft Store package
Post Reply
skylight1
Posts: 3
Joined: 23 Nov 2021, 05:29

Making a preset for photo date created (or modified)

Post by skylight1 »

Hi there,

I am a little new to presets in Filebot, and am looking for help in renaming a large collection of photos. I started with a basic preset that would use folder name and create an image order sequence in that given collection:

Code: Select all

{folder.name} - {i.pad(3)}
Then I looked to add information, when available in file metadata, like camera model and date photo taken:

Code: Select all

{folder.name} - {i.pad(3)}{" | $dt.format('yyyy-MM-dd')"}{" | $camera.model"}
This works perfectly for the camera model, but not for the date. I presume the $ does not work for dt, or that my syntax is incorrect, but I couldn't quite figure out what was wrong there. When I use this without the $ in front of dt.format, it works, but a huge % of my pictures don't contain date values for that call, and therefore no date value is put into the file name. I then came across a forum post below which detailed how to alternatively use date modified, presumably because this was a more accurate representation of when the photo was taken compared to OS date created (but this is using CLI which I am not confident in attempting at this time). I thought this was an even more elegant solution as I'd prefer to have a date in the file name - it's more important to me that a date is there, whereas camera model is just optional added info. Is there an easy way to implement this in a one line preset like I've been working on? Many thanks in advance for any help anyone can provide here, and apologies if this has been answered elsewhere. I have been looking for other posts or guides to no avail.

Ideal format: [folder name] - [# in sequence] [ | date photo taken/modified] [ | camera model]

This way, the pipe separators are only injected when metadata values are found.

I lastly tried just plugging in that line into a preset, and it works, but I don't think I want to use the new command (I quite frankly don't understand it or what it does).

Code: Select all

{folder.name} - {i.pad(3) } | {new Date(file.lastModified()).dateTimeString}{" | $camera.model"}
Forum post: viewtopic.php?t=5879

Image

Image
Last edited by skylight1 on 23 Nov 2021, 06:45, edited 1 time in total.
User avatar
rednoah
The Source
Posts: 20273
Joined: 16 Nov 2011, 08:59

Re: Making a preset for photo date created (or modified)

Post by rednoah »

e.g.

Code: Select all

{folder.name} - {i.pad(3)} - {dt.format('yyyy-MM-dd')} - {camera.model}
Image


:idea: Note that dt is based on the EXIF Date-Taken image metadata field, as opposed to file.lastModified() which is simply the Last-Modified file system attribute. Selecting Datasource: Exif Metadata would allow you to preemptively ignore files that aren't tagged.


:!: Note that | PIPE is a special character that should not be used in actual file paths. You can use it for testing though.


:arrow: Please read Groovy Syntax :: 4.4.1. String interpolation for details on how $variable.property and ${expression} work.
:idea: Please read the FAQ and How to Request Help.
User avatar
rednoah
The Source
Posts: 20273
Joined: 16 Nov 2011, 08:59

Re: Making a preset for photo date created (or modified)

Post by rednoah »

e.g. here's some additions to make it work better for files that don't have any EXIF image metadata:

Code: Select all

{ folder.name } - { i.pad(3) }{ ' - ' + any{ dt }{ f.creationDate }.format('yyyy-MM-dd') }{ ' - ' + camera.model }
:idea: Please read the FAQ and How to Request Help.
skylight1
Posts: 3
Joined: 23 Nov 2021, 05:29

Re: Making a preset for photo date created (or modified)

Post by skylight1 »

Thanks rednoah for the quick replies and tip about pipes - noted! I really appreciate all your help.

When I try using the Exif Metadata datasource on the preset, a large number of photos simply fail to place any info whatsoever, not sure why. Pastebin link of debug info included.

https://pastebin.com/B6f78RgX

Code: Select all

{folder.name} - {i.pad(3)} - {dt.format('yyyy-MM-dd')} - {camera.model}
Image

Using your most recent suggestion I get the output in my desired format, but I am still missing date info for many photos. Do you have any other suggestions on how to improve this? I know that we can't show data when it doesn't exist, but I'm wondering if we could use multiple fields in an ordered preference, or if a different field may be present 100% of the time even if it's not a perfectly accurate as a representation of the actual date taken. I'm honestly not sure which outcome would be better, and I'm just trying to learn along the way.

Code: Select all

{ folder.name } - { i.pad(3) }{ ' - ' + any{ dt }{ f.creationDate }.format('yyyy-MM-dd') }{ ' - ' + camera.model }
Image
User avatar
rednoah
The Source
Posts: 20273
Joined: 16 Nov 2011, 08:59

Re: Making a preset for photo date created (or modified)

Post by rednoah »

Most strange... AFAIK, f.creationDate cannot be undefined...

1. Pick a file that doesn't show a date
2. Double-Click ➔ Edit Format ➔ Use { f.creationDate } as format for testing (and nothing else, so that you can see the error message and attribute it specifically to this piece of code)
3. What does the error message say?



EDIT:

:idea: Datasource: Exif Metadata will indeed ignore files that don't have EXIF metadata, e.g. drop in all the images, but only match the photos, and not the screenshots. Photos without EXIF metadata is most strange though. Any camera produced in in the last 15+ years would have added lots of metadata when the JPG file was first created.
:idea: Please read the FAQ and How to Request Help.
skylight1
Posts: 3
Joined: 23 Nov 2021, 05:29

Re: Making a preset for photo date created (or modified)

Post by skylight1 »

Thanks again rednoah - super appreciated!

I don't know why some of my actual photos were missing EXIF metadata, but that bothered me more than it should. My photos are a hodge podge collection of imported, copied, backed up and restored files that have been touched by multiple file systems and applications, and I assume that somewhere along the way in prior years where I knew less, EXIF metadata was lost or erased inadvertently. I wanted to circle back and provide the following information for you or anyone else who may stumble across similar problems in the future:

I used High Motion Software's free program called ImBatch to create an automated job that would populate EXIF metadata for exif.DateTimeOriginal only when the field was empty/null, replacing the value with the data available in the file system's Date Created field. I used a filter expression (Get_EXIF_DateTimeOriginal_D = 0)) as a part of ImBatch's job to avoid modifying any files where there was valid EXIF metadata. This date, by everything I can see, is a very close date to the true date taken on the photo - and that was better, for me, than having null values. Other experiences may vary.

Once my EXIF metadata was corrected, I used the below preset with Datasource:Plain File in Filebot to rename, and this had my desired outcome. Hope this helps someone else - and thanks again for your prompt support! Also, a great explanation on the metadata involved in this can be found here:

https://feedback-readonly.photoshop.com ... y_17881341

Code: Select all

{folder.name} - {i.pad(3)} - {Date.parse('yyyy:MM:dd HH:mm:ss', exif.DateTimeOriginal).format('yyyy-MM-dd')}{" - $camera.model"}
Image
Post Reply