INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Expression Help: Fill Date from Filename  (Read 714 times)

darichman

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1362
Expression Help: Fill Date from Filename
« on: September 01, 2018, 10:28:29 pm »

Hi team

I'm having trouble filling date info from the filename for my images.

Background: I use an expression to rename my photos
  [date (filename friendly)] - [name]
For a file dated March 2nd 2008 1:59:31 pm this gives an output like:
  20080302-135931 - Picture 020.jpg

Unfortunately editing in an external program (lightroom) has resulted in the time element missing in MC's  [Date] field from several hundred of my photos. So [Date] in the above file changes to 2/03/2008 (without a time)

I would like to refill the time info using 'Fill Properties from Filename' as the time info is still in the filename. I cannot get this to work though.

Using either [Date (filename friendly)] - [name]  or [Date] - [name] just seems to read as 20080302-000000 - Picture 020

Any ideas would be really helpful! Thanks in advance

(For anyone wondering, I am using lightroom for facetagging and storing people names in the [Keyword] field for use in MC, but this resets the time field in files which I have previously manually tagged in MC - potentially as the data isn't hard-stored into EXIF date fields?)
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Expression Help: Fill Date from Filename
« Reply #1 on: September 02, 2018, 02:04:23 am »

Your problem is that the [Date (filename friendly)] field is a calculated field, and is not user editable. So you can't directly update it using the "Fill Properties From Filename" function.

You need to update the [Date] field, which will then update the [Date (filename friendly)] automatically. That means you need to take the value from your filename in the form "20080302-135931" and convert it to a form that will import correctly into the [Date] field, in the format "2/03/2008 1:59 pm". Basically, you need to do the reverse of "FormatDate(Filename)", which converts the [Date] field to the [Date (filename friendly)] field.

Hmmm. That reverse conversion looked hard. So I created a copy of one of my image files, renamed it using the expression "FormatDate(Filename) - [Name]", and then deleted the [Date] field for that image, which then cleared the [Date (filename friendly)] field, giving me the same situation you are in. I tried a few expressions, and couldn't get it to work. Then I thought I would just try "Automatic" in the "Fill Properties From Filename" function, and boom, MC found the Date field and correctly formatted it. It only found the [Date] field, and not the [Name], but that is all you needed. I saved what the "Fill Properties From Filename" function was suggesting, and both the [Date] and  [Date (filename friendly)] fields were filled in correctly.

Sometimes we just try too hard, for something that is simple. I still don't know how to do the same thing using a template, but that hardly matters!

The attached image shows my original image, my test image without a [Date] value, and what the "Fill Properties From Filename" function finds. Works a treat.



PS: Not good that Lightroom strips the time from the "Date Taken" field. That field should be sacrosanct and never altered.
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: Expression Help: Fill Date from Filename
« Reply #2 on: September 02, 2018, 02:21:51 am »

"Filename friendly" is just a number derived from the date.

Assuming that all of the affected files follow the same naming pattern, you can do this directly in the tag window...

Pick a file.
click in the date field to open it for editing.
paste this into the date field (It will return dd/MM/yyyy)
Code: [Select]
=mid([filename (name)],6,2)//mid([filename (name)],4,2)//mid([filename (name)],0,4) mid([filename (name)],9,2):mid([filename (name)],11,2):mid([filename (name)],13,2)Press enter.

Happy?
Select all of the affected files and repeat.
Job done.

darichman

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1362
Re: Expression Help: Fill Date from Filename
« Reply #3 on: September 02, 2018, 02:26:09 am »

RoderickGI, you have saved me hours of work - thank you.

I have never in my life used the 'automatic' feature in the fill properties dialogue - looks like the dev team sorted out that wizardry years ago :)

PS: Not good that Lightroom strips the time from the "Date Taken" field. That field should be sacrosanct and never altered.

I'm not sure it's actually lightroom stripping the time - this occurs for me in images which have either been digitally downloaded or scanned, and so lack the time info to begin with. I've then manually entered times (if they exist or to facilitate photo order) in the MC [date field]. Something must then happen when MC reads the updated metadata after lightroom editing and it's wiping the date time info when it imports keywords etc.

The best solution for me would be if I could force MC to write the correct date info to EXIF.
This is a good workaround though, thanks again

Edit: Marko you posted while I was typing. You have solved no less than a dozen of my expression-related woes over the years. Thanks - that's great!
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Expression Help: Fill Date from Filename
« Reply #4 on: September 02, 2018, 02:52:50 am »

You should probably run "Update tags from Library" for the affected files after using either solution. At least then the "Date Taken" should be in the file correctly, although that will change the "Date Modified".

I thought someone was working on MC updating the EXIF data in images. Maybe it was just importing data from EXIF. Worth a bit of research.
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner
Pages: [1]   Go Up