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:Users
(*alias Macintosh HD:Users
(*{"Caption", "Caption Writer", "Headline"}*)
set file iptc alias "Macintosh HD:Users
--> 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