Hello all:
I recently scanned a large number of old non-digital photos and I built an Excel spreadsheet of the metadata for these photos. I want to import this information into the photos.
I used the ‘get file IPTC’ to find the correct order of the IPTC items, and used the following script to do a write test with the ‘set file iptc’command. And I was able to write data to each of the different items, using the script:
set theGraphicFile to choose file with prompt "Select a graphic file:"
tell application "GraphicConverter 11"
display dialog "theGraphicFile is " & the theGraphicFile
set file iptc theGraphicFile to {"Caption", "Caption Writer", "Headline", "Origen: Special Instructions", "Credits: Byline", "Credits: By-line Title", "Credits: Credit", "Credits: Source", "Title", "Origen: Creation Date/Time", "Origen: City", "Origen: Province/State", "Origen: Country", "Origen: Reference", "Category", "Supp Categories", "Urgency", "Keywords", "Copyright: Notice", "Copyright: URL", "Event", "People", "Credits: Status", "Origen: Location", "Contact Info: City", "Contact Info: Country", "Contact info: Address", "Contact info: Postal Code", "Contact Info: Region", "Contact Info: Email", "Contact Info: Phone", "Contact Info: Web URL", "Origen: ISO Cty Code", "Copyright: Rights Usage Terms", "Rating"}
end tell
And this writes all of the IPTC data to the photo.
So, I put a shorter form of this data, formatted like the data above, into an Excel cell to try to read it from Excel and write to the photo.
{“Caption”, “Caption Writer”, ‘Headline”}
But when I try to read data from the Excel sheet and write to GC-11, with this script, I get a parameter error.
tell application "Microsoft Excel"
activate
set myCol to 1 -- the starting column
set myRow to 2 -- the starting row
select (cell myCol of row myRow of active sheet)
tell cell myCol of row myRow
set myVal to value
end tell
display dialog (myCol as text) & "," & (myRow as text) & " " & myVal
tell application "GraphicConverter 11"
set theGraphicFile to choose file with prompt "Select a graphic file:"
log theGraphicFile
log myVal
set file iptc theGraphicFile to myVal
end tell
end tell
Here’s the log.
tell application "Microsoft Excel"
activate
select cell 1 of row 2 of active sheet
get value of cell 1 of row 2
--> "{\"Caption\", \"Caption Writer\", \"Headline\"}"
display dialog "1,2 {\"Caption\", \"Caption Writer\", \"Headline\"}"
--> {button returned:"OK"}
end tell
tell application "GraphicConverter 11"
choose file with prompt "Select a graphic file:"
--> alias "Macintosh HD:UsersPictures:M&D imgs-scrpt test:img007 w-iptc.jpg"
(*alias Macintosh HD:UsersPictures:M&D imgs-scrpt test:img007 w-iptc.jpg*)
(*{"Caption", "Caption Writer", "Headline"}*)
set file iptc alias "Macintosh HD:UsersPictures:M&D imgs-scrpt test:img007 w-iptc.jpg" to "{\"Caption\", \"Caption Writer\", \"Headline\"}"
--> error number -50
Result:
error "GraphicConverter 11 got an error: Parameter error." number -50
I don’t understand why the data in the excel file, {“Caption”, “Caption Writer”, ‘Headline”}
gets changed to {"{\"Caption\", \"Caption Writer\", \"Headline\"}"}
I’m obviously a beginner at Applescript, what am I doing wrong?
John
[Solved] Read data from Excel, write to IPTC problem
-
- Posts: 3
- Joined: Thu Mar 18, 2021 3:16 pm
- Country: USA
- forum_adm
- Site Admin
- Posts: 1819
- Joined: Fri Dec 23, 2016 9:41 am
- Location: Germany
- Country: Germany
- Contact:
Re: Read data from Excel, write to IPTC problem
I did not check your AppleScript, yet. Because I am not an AppleScript expert, too.
I suggest to use the Export and Import feature in the GraphicConverter browser.
So, you can Export an empty spreadsheet with all paths. Fill the data and import the data back.
That is much more simple.
Thorsten
I suggest to use the Export and Import feature in the GraphicConverter browser.
So, you can Export an empty spreadsheet with all paths. Fill the data and import the data back.
That is much more simple.
Thorsten
- forum_adm
- Site Admin
- Posts: 1819
- Joined: Fri Dec 23, 2016 9:41 am
- Location: Germany
- Country: Germany
- Contact:
Re: Read data from Excel, write to IPTC problem
Also, the set iptc command requires a minimum of 22 fields in the table. Just set empty field to "".
-
- Posts: 3
- Joined: Thu Mar 18, 2021 3:16 pm
- Country: USA
Re: Read data from Excel, write to IPTC problem
Thank you, that works except for one thing; it does not write the Origen:Creation Date to IPTC. I see that there is a way to set the Exif date under the camera menu, and then I can copy the EXIF date to the IPTC date under the IPTC menu. But it looks like I would need to do this separately for each photo. Is there a way that I can write creation dates from an excel file to the photos?
John
John
- forum_adm
- Site Admin
- Posts: 1819
- Joined: Fri Dec 23, 2016 9:41 am
- Location: Germany
- Country: Germany
- Contact:
Re: Read data from Excel, write to IPTC problem
I just rechecked.
The creation date is exported:
Thorsten
The creation date is exported:
Thorsten
- forum_adm
- Site Admin
- Posts: 1819
- Joined: Fri Dec 23, 2016 9:41 am
- Location: Germany
- Country: Germany
- Contact:
Re: Read data from Excel, write to IPTC problem
Please e-mail a sample xlsx file for testing to support@lemkesoft.de if the reimport of the creation date does not work.
-
- Posts: 3
- Joined: Thu Mar 18, 2021 3:16 pm
- Country: USA
Re: Read data from Excel, write to IPTC problem
I found the problem I was having. I was using an incorrect format for the date/time. Everything is working fine now. Thank you for the help.
John
John