Skip to main content
Inspiring
August 9, 2012
Answered

Applescript, XMP, and custom namespaces

  • August 9, 2012
  • 2 replies
  • 4243 views

Having had to switch gears from JS to AS to solve a database integration problem, I could use some help getting specific XMP out of my AI files via AppleScript. Extracted this from the InDesign forums... doesn't work for illustrator (gives error "expected expression but found property")

tell links

            set InhouseClient to get property link xmp namespace "http://ns.Inhouse.com/Inhouse" path "Client"

end tell

I know I can dump the whole XMP string with:

set XMPStringData to (get XMP string of current document)

but I'd rather do something like the first example. If I were in JS, I'd use

var property = myXmp.getProperty(propertyuri, propertyname, XMPConst.STRING);

The syntax looks pretty close to the first AppleScript, but why is it choking on the "property" when inside a "tell Illustrator" when is works inside a "tell InDesign"?

This topic has been closed for replies.
Correct answer aklyman

The above worked fine here listing all folders on my startup drive… Im at home so I can't check with mounted share… Some OS versions don't like the escaped quoting ie the \" but its best to get served by those who are up to date on AppleScript… If ExifTool works for you then you would find | filter | exiftool. Anyhows Im sure you will find a much faster solution than what you currently have…


Oh my lord working with shell is FAST!!!

Working on a remote server, a little applescript calling a shell script is capturing the path for 20,000+ files in 2000+ jobs in a little over 5 minutes to ingest into my FMPro database. The applescript alone would have taken 30+ hours, and was getting interrupted by server time-outs.

Mark's "mdfind" wasn't working for me, probably because I was defaulting to a different shell script language.  What is working for me:

set fileString to (do shell script "find " & quoted form of searchPath & " -maxdepth 1 -iname *.ai")

which writes a list of off the paths to AI files found within the searchPath passed to the shell script.

Next step is to add a xmp lookup subroutine using EXIFTool... initial tests tell me this is the easy part.

Signed,

Recovering GUI Addict.

2 replies

April 23, 2013

Hi

I just saved each layer of text to pdf and then saved each pdf to xml, no scripting involved.

Ali

Larry G. Schneider
Community Expert
Community Expert
August 9, 2012

Have you looked at the possibility of using the AS "do javascript" command?  From the manual

do javascript

Executes a JavaScript script and returns the result of execution.

aklymanAuthor
Inspiring
August 9, 2012

I am considering this, but want to avoid as many moving peices as possible. I'm using FileMakerPro to create a calculation-defined AppleScript to extract XMP from Adobe CS files. I could pass parameters from the AS to the JS and back, but doing it all in AS would streamline both the development and (possibly/hopefully) shorten the run time. Preliminary tests using AS just to get the filepaths of the files I want from an irregular filesystem is already taking 10+ hours. I can call the XMP extract as a separate process, but expect similar time to run. Fewer moving parts = less time and more reliability.

Might have to do it this way though. In fact, may want to. I suspect (probably erroneously) that JS will execute faster than AS, so if I have JS do the hard work of the lookup... hmmm, don't know how to test that to get real metrics.

Anyone know if Finder (via AS) can extract XMP from AI files without telling illustrator to open the file first? FMP needs an add-on to do it (I think).

Thanks,

Alex

Inspiring
August 10, 2012

I think you are in the wrong forum for this kind of scripting… I would NOT want to be opening AI files to extract XMP metadata. Using Adobe's ExtendScript I would either script Bridge or load the ESTK's external XMP library… This would be much much faster. That said FMP is AppleScript friendly ( wish I had it ). IMO you want to be looking at AppleScript's do shell script command this will blow Finder's little cotton socks off… You should take a look at ExifTool ( a great utility )…

http://www.sno.phy.queensu.ca/~phil/exiftool/

and ask your question either here:

http://www.macscripter.net/viewforum.php?id=2

or

https://discussions.apple.com/community/mac_os/mac_os_x_technologies?view=discussions&tagSet=1044#/

I would want finding files done in seconds/minutes NOT in hours? Do tell us more…?