• 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: mdls & .app?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mdls & .app?


  • Subject: Re: mdls & .app?
  • From: Christopher Stone <email@hidden>
  • Date: Sun, 20 Feb 2011 09:22:37 -0600

On Feb 20, 2011, at 02:44, Steve Thompson wrote:
On 20 Feb 2011, at 03:36, Christopher Stone wrote:
# Does not work:
set theApp to "/Applications/TextEdit.app"
set cmd to "mdls " & theApp
do shell script cmd

It works here:

set theApp to "/Applications/TextEdit.app"
set cmd to "mdls -name kMDItemLastUsedDate " & theApp
do shell script cmd
______________________________________________________________________

Hey Steve,

These two bits of code are not the same, although your syntax does work here and is good to know.  It will allow me to do what I want to do although not as neatly as if 'mdls' worked the same as with a file.

The output I would expect from: 'mdls /Applications/TextEdit.app' is similar to this which comes from a test text file in the Applications Folder:

kMDItemContentCreationDate     = 2011-02-05 16:36:34 -0600
kMDItemContentModificationDate = 2011-02-05 16:36:34 -0600
kMDItemContentType             = "public.plain-text"
kMDItemContentTypeTree         = (
    "public.plain-text",
    "public.text",
    "public.data",
    "public.item",
    "public.content"
)
kMDItemDisplayName             = "test.txt"
kMDItemFSContentChangeDate     = 2011-02-05 16:36:34 -0600
kMDItemFSCreationDate          = 2011-02-05 16:36:34 -0600
kMDItemFSCreatorCode           = ""
kMDItemFSFinderFlags           = 0
kMDItemFSHasCustomIcon         = 0
kMDItemFSInvisible             = 0
kMDItemFSIsExtensionHidden     = 0
kMDItemFSIsStationery          = 0
kMDItemFSLabel                 = 0
kMDItemFSName                  = "test.txt"
kMDItemFSNodeCount             = 0
kMDItemFSOwnerGroupID          = 80
kMDItemFSOwnerUserID           = 501
kMDItemFSSize                  = 17639
kMDItemFSTypeCode              = ""
kMDItemKind                    = "BBEdit text document"
kMDItemLastUsedDate            = 2011-02-05 16:36:34 -0600
kMDItemUsedDates               = (
    "2011-02-05 00:00:00 -0600"
)
kMDItemWhereFroms              = (
    "http://hayne.net/MacDev/Bash/aliases.bash"
)

What I actually get from 'TextEdit.app' is zippo from the command line or "" from a do shell script in Applescript.

I do realize of course that the metadata for a directory will be different than that of a file, but an application is a pseudo file and therefore should behave similarly with tools like 'mdls' - or so it seems to me.

I can do something like this and accomplish what I want:

set theApp to "/Applications/TextEdit.app"
set cmd to "mdls \\
 -name kMDItemFSName \\
 -name kMDItemKind \\
 -name kMDItemFSCreationDate \\
 -name kMDItemFSContentChangeDate \\
 -name kMDItemLastUsedDate \\
 -name kMDItemUsedDates \\
 " & theApp
set mdlsOutput to do shell script cmd

Curiously though the output is not in the order I've specified in the command.

Also in the following I'm not able to get the -nullmarker string to change from null.

set cmd to "mdls \\
 -name kMDItemFSName \\
 -name kMDItemKind \\
 -name kMDItemFSCreationDate \\
 -name kMDItemFSContentChangeDate \\
 -name kMDItemLastUsedDate \\
 -raw \\
 -nullMarker \", \" \\
 /Applications/TextEdit.app"

So I'm having to resort to:

set mdlsOutput to do shell script cmd
set AppleScript's text item delimiters to (character id 0)
text items of mdlsOutput

This is not a big problem, but I'd like to know if my syntax is wrong for -nullmarker or if I've hit a bug.

--
Best Regards,
Chris
 _______________________________________________
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

  • Follow-Ups:
    • Re: mdls & .app?
      • From: Luther Fuller <email@hidden>
References: 
 >mdls & .app? (From: Christopher Stone <email@hidden>)
 >Re: mdls & .app? (From: Steve Thompson <email@hidden>)

  • Prev by Date: Re: Applescript runner authentication
  • Next by Date: Re: Applescript runner authentication
  • Previous by thread: Re: mdls & .app?
  • Next by thread: Re: mdls & .app?
  • Index(es):
    • Date
    • Thread