Skip navigation
inanealex2010
Currently Being Moderated

Applescript, XMP, and custom namespaces

Aug 8, 2012 8:06 PM

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"?

 
Replies
  • Currently Being Moderated
    Aug 9, 2012 9:06 AM   in reply to inanealex2010

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 10, 2012 12:38 AM   in reply to inanealex2010

    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?v iew=discussions&tagSet=1044#/

     

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

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 10, 2012 7:59 AM   in reply to inanealex2010

    Alex, you are using a combo of 2 AppleScript commands that are easy to write but the trade off is they are notoriously slow to execute… entire contents in finder takes an age plus the whose filtering you rearly need to swap this out for a little shell… do shell script has a memory overhead so call it as few times as possible but once called its fast… Do you need to locate just *.ai files in grahics folders or could you generic search *.ai?

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 10, 2012 8:38 AM   in reply to inanealex2010

    It's been some time since I last used AppleScript & Shell but does this work to find your folders?

     

    set This_Folder to (choose folder with prompt "Select your top level folder…" without invisibles)

     

    set Folder_List to paragraphs of (do shell script "mdfind -onlyin " & quoted form of POSIX path of This_Folder & " 'kMDItemKind == \"Folder\" && kMDItemDisplayName == \"Graphics'")

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 10, 2012 9:14 AM   in reply to inanealex2010

    What version of the OS are you running…? My AppleScript has become a little rusty… There are numberous ways to do what you want but you would be better served asking where I showed you… Basically you just need pipe two commands find | filter…

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 10, 2012 9:46 AM   in reply to inanealex2010

    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…

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 10, 2012 10:33 AM   in reply to inanealex2010

    I did say it would blow finder's little cotton socks off… Glad you got it working…

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 23, 2013 2:08 AM   in reply to inanealex2010

    Hi

     

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

     

    Ali

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points