the following script successfully parses adobe xmp-data from an image file:
set myFolder to read (choose file)
set theContents to myFolder
property captionBeginning : “xmlns:dc=‘http://purl.org/dc/elements/1.1/’>
dc:formatimage/jpeg</dc:format>
dc:title
rdf:Alt
<rdf:li xml:lang=‘x-default’>”
property captionEnd : “</rdf:li>
</rdf:Alt>
</dc:title>”
set originalDelimiters to AppleScript’s text item delimiters
set AppleScript’s text item delimiters to {captionBeginning}
set theItems to text items 2 thru (count of text items of theContents) of theContents
set captionArray to {}
set AppleScript’s text item delimiters to {captionEnd}
repeat with nextItem in theItems
set captionArray to captionArray & first text item of nextItem
end repeat
set AppleScript’s text item delimiters to originalDelimiters
display dialog captionArray
property photoBeginning : “</rdf:li>
</rdf:Alt>
</dc:title>
dc:creator
rdf:Seq
rdf:li”
property photoEnd : “</rdf:li>
</rdf:Seq>
</dc:creator>
</rdf:Description>”
set originalDelimiters to AppleScript’s text item delimiters
set AppleScript’s text item delimiters to {photoBeginning}
set theItems to text items 2 thru (count of text items of theContents) of theContents
set photoArray to {}
set AppleScript’s text item delimiters to {photoEnd}
repeat with nextItem in theItems
set photoArray to photoArray & first text item of nextItem
end repeat
set AppleScript’s text item delimiters to originalDelimiters
display dialog "©2007 " & photoArray
i think i originally found the bulk of this script on this forum! a couple modifications and this script has already saved me from hours of painful typographical work. i’m having trouble, however, with altering one of the command lines. i’d like to have the script read a variable or file path, but the “read” command only seems to work with file prompts.
what i’d like to do isn’t too dramatic. i just want to change:
“set myFolder to read (choose file)” to “set myFolder to read (myVariable)”.
with this change i get the following error message:
Can’t make “comp2:users:gregd:desktop:test_image.jpg” into a file.
the script which returns the error message is below:
set myVariable to “comp2:users:gregd:desktop:test-image.jpg”
set myFolder to read (myVariable)
set theContents to myFolder
property captionBeginning : “xmlns:dc=‘http://purl.org/dc/elements/1.1/’>
dc:formatimage/jpeg</dc:format>
dc:title
rdf:Alt
<rdf:li xml:lang=‘x-default’>”
property captionEnd : “</rdf:li>
</rdf:Alt>
</dc:title>”
set originalDelimiters to AppleScript’s text item delimiters
set AppleScript’s text item delimiters to {captionBeginning}
set theItems to text items 2 thru (count of text items of theContents) of theContents
set captionArray to {}
set AppleScript’s text item delimiters to {captionEnd}
repeat with nextItem in theItems
set captionArray to captionArray & first text item of nextItem
end repeat
set AppleScript’s text item delimiters to originalDelimiters
display dialog captionArray
property photoBeginning : “</rdf:li>
</rdf:Alt>
</dc:title>
dc:creator
rdf:Seq
rdf:li”
property photoEnd : “</rdf:li>
</rdf:Seq>
</dc:creator>
</rdf:Description>”
set originalDelimiters to AppleScript’s text item delimiters
set AppleScript’s text item delimiters to {photoBeginning}
set theItems to text items 2 thru (count of text items of theContents) of theContents
set photoArray to {}
set AppleScript’s text item delimiters to {photoEnd}
repeat with nextItem in theItems
set photoArray to photoArray & first text item of nextItem
end repeat
set AppleScript’s text item delimiters to originalDelimiters
display dialog "©2007 " & photoArray
if anyone has any ideas, it would be a great help!