• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Meta data help
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Meta data help


  • Subject: Re: Meta data help
  • From: Martin Orpen <email@hidden>
  • Date: Fri, 27 Jun 2008 20:10:50 +0100

On 27 Jun 2008, at 18:16, Oakley Masten wrote:

tell application "Finder"
set theFile to choose file
set foo to POSIX path of theFile --(selection as alias)

--This returns the File Path and the complete list of metadata fields and their names
--The list no longer includes kMDItemKeywords but it use to.
display dialog (do shell script "mdls " & quoted form of foo)

--this returns the File Path and requested items from the list as stated that it would
--How do I get it to only return the requested data and leave off the file path?
display dialog (do shell script "mdls -name kMDItemPageWidth -name kMDItemPageHeight " & quoted form offoo)

--this returns the File Path and "nothing" as the kMDItemKeywords is missing from the list
--It use to show the Keywords as they were part of the total list but are no longer there.
display dialog (do shell script "mdls -name kMDItemKeywords " & quoted form of foo)

end tell


Thanks for your previous help Martin.

What do I do next?

Reboot! ;-)

I'm using 10.5.3 and kMDItemKeywords works as expected -- so maybe there is a problem in 10.4 or more likely you've got a local problem with your Mac?

The script shouldn't be returning a file path, just the name of the field that you've requested and if it is empty then it should also return "(null)".

Removing everything but the data you want can sometimes be tricky and I tend to use tools like awk to do this when using the shell. But, as you know the length of the junk that you want to get rid of it is easy to get around this problem by getting AppleScript to ignore it:


tell application "Finder"
set foo to POSIX path of (choose file)
set bar to (do shell script "mdls -name kMDItemKeywords " & quoted form of foo)
if bar contains "(null)" then
display dialog "No keywords here"
else
display dialog (items 23 thru -3 of bar) as string
end if
end tell


--> "spot colour",
    PMS,
    TOYO,
    PANTONE


Regards

--
Martin Orpen
Idea Digital Imaging Ltd


_______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
References: 
 >Meta data help (From: Oakley Masten <email@hidden>)

  • Prev by Date: Re: AppleScript-Users Digest, Vol 5, Issue 391
  • Next by Date: Re: can applescript monitor keyboard input
  • Previous by thread: Meta data help
  • Next by thread: Re: AppleScript-Users Digest, Vol 5, Issue 391
  • Index(es):
    • Date
    • Thread