Author Topic: Importing metadata  (Read 3855 times)

Offline DavidHoffmanuk

  • Sr. Member
  • ****
  • Posts: 313
    • View Profile
Importing metadata
« on: May 13, 2022, 10:42:39 AM »
I have a (long) list of filenames and dates. Is there a way to import these dates into the corresponding files in  PM, preferably into the date field?

David Hoffman

Offline ahoward

  • Camera Bits Staff
  • Hero Member
  • *****
  • Posts: 939
    • View Profile
Re: Importing metadata
« Reply #1 on: May 13, 2022, 05:07:37 PM »
What format is this list in? Is it a text file? Spreadsheet?

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 24970
    • View Profile
    • Camera Bits, Inc.
Re: Importing metadata
« Reply #2 on: May 14, 2022, 10:35:59 PM »
Regardless of the file format, there is currently no way to import dates.

-Kirk

Offline DavidHoffmanuk

  • Sr. Member
  • ****
  • Posts: 313
    • View Profile
Re: Importing metadata
« Reply #3 on: May 15, 2022, 01:17:42 AM »
Quote
Kirk:
What format is this list in? Is it a text file? Spreadsheet?

It's currently in a spreadsheet though it could be converted to any format that works - but your next reply makes that redundant. I'll see if I can hack one the Media Pro Applescripts or its XML import function.

David

Offline ahoward

  • Camera Bits Staff
  • Hero Member
  • *****
  • Posts: 939
    • View Profile
Re: Importing metadata
« Reply #4 on: May 16, 2022, 09:49:36 AM »
Quote
Kirk:
What format is this list in? Is it a text file? Spreadsheet?

It's currently in a spreadsheet though it could be converted to any format that works - but your next reply makes that redundant. I'll see if I can hack one the Media Pro Applescripts or its XML import function.

David

Well, PM could put the date from that spreadsheet into any text field easily. Since you said it would preferable that it sets the capture time or IPTC date of the image, I assume you may get some use out of this even if it’s not exactly what you were after. Can provide more info if you would find this useful.

Offline DavidHoffmanuk

  • Sr. Member
  • ****
  • Posts: 313
    • View Profile
Re: Importing metadata
« Reply #5 on: May 16, 2022, 11:52:37 AM »
I have a few thousand files named in the form [date as YYMMDD] [description] [serial] - EG "100112 Love Police 108". The 100112 equates to Jan 12 2010.

I have another few thousand that already have the dates in the IPTC date field. I want to merge these sets and to be able to work with them using their dates and I also want to generate filename & date lists covering different date ranges for © registration.

I can export a text list of the filenames that have the date prefix and it's easy pull the date string out and parse it to whatever form is needed with Excel. That gives me a list of original filenames in one column, the dates in the next column. That can be turned into a csv or whatever.

I'd like to be able to have PM read the list and insert the date into each file, ideally the IPTC creation date. Or is it possible to create custom fields?

Thanks
David

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 24970
    • View Profile
    • Camera Bits, Inc.
Re: Importing metadata
« Reply #6 on: May 16, 2022, 01:42:20 PM »
David,

I'd like to be able to have PM read the list and insert the date into each file, ideally the IPTC creation date. Or is it possible to create custom fields?

There exists no facility to put a value into the IPTC creation date.  There also is no way to create custom fields in Photo Mechanic Plus.

I suggest using some scripting along with ExifTool for setting the creation date.

-Kirk

Offline DavidHoffmanuk

  • Sr. Member
  • ****
  • Posts: 313
    • View Profile
Re: Importing metadata
« Reply #7 on: May 16, 2022, 11:32:55 PM »
Thanks for the update Kirk. If the IPTC date field is not modifiable and I can't create a custom field it would still be a help if I could import the dates into an otherwise unused field. I thought that ahoward's reply above implied that this could be a possibility.

David

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 24970
    • View Profile
    • Camera Bits, Inc.
Re: Importing metadata
« Reply #8 on: May 17, 2022, 09:41:32 AM »
David,

Thanks for the update Kirk. If the IPTC date field is not modifiable and I can't create a custom field it would still be a help if I could import the dates into an otherwise unused field. I thought that ahoward's reply above implied that this could be a possibility.

Yes, it is possible via Code Replacement.  Andrew will post a set of steps for you to follow.

-Kirk

Offline ahoward

  • Camera Bits Staff
  • Hero Member
  • *****
  • Posts: 939
    • View Profile
Re: Importing metadata
« Reply #9 on: May 17, 2022, 10:24:49 AM »
Thanks for the update Kirk. If the IPTC date field is not modifiable and I can't create a custom field it would still be a help if I could import the dates into an otherwise unused field. I thought that ahoward's reply above implied that this could be a possibility.

David

So you'll want to save that spreadsheet as a TSV with the filename in the first column, and then save it as a UTF_8 formatted txt file. Then, use that as your code replacement file: https://docs.camerabits.com/support/solutions/articles/48000223660-introduction-to-code-replacements-in-photo-mechanic

Then, in the field where you would like this information, you'll want to use the filename variable inside of the code replacement delimiters, and then apply that in a Metadata Template to all the images that the spreadsheet has the information about. My code replacement delimiter is: =

If your spreadsheet has the extension on the filenames, you would use the following:
={filename}=

If your spreadsheet does not have the extension, you would use this:
={filenamebase}=

Photo Mechanic will evaluate the variable, giving you the full filename or the base of the filename, and then it will use the result to look for text to replace it with in the code replacement file. By default it will replace the text that it finds in the first column with the text in the next column, but you can have it use text from any number of columns: https://docs.camerabits.com/support/solutions/articles/48000358641-advanced-code-replacements

Hope that helps!

Offline Mick O (Camera Bits)

  • Camera Bits Staff
  • Hero Member
  • *****
  • Posts: 547
    • View Profile
    • Camera Bits
Re: Importing metadata
« Reply #10 on: May 17, 2022, 11:26:47 AM »
We also have a video showing how you could do it with "hot code" style code replacements (slightly different than Andrew described, but both will work) 

Apply Metadata From a Spreadsheet using Photo Mechanic
https://www.youtube.com/watch?v=XHyl5inFvFs

And I will add that the "Supplemental Category"  IPTC fields in Photo Mechanic are often good choices to store custom data. Those fields were deprecated by the IPTC so there is no current conflict for using them however you want.  Hope this helps.


-Mick
Mick O
Camera Bits

Offline DavidHoffmanuk

  • Sr. Member
  • ****
  • Posts: 313
    • View Profile
Re: Importing metadata
« Reply #11 on: May 18, 2022, 08:15:30 AM »
Many thanks Andrew and Mick!

This looks like a comprehensive solution and I can see it being helpful more widely. I'll make a test catalog to start with, get going on it over the weekend and post again if I run into trouble.

David