Re: Getting Info from the Finder
Re: Getting Info from the Finder
- Subject: Re: Getting Info from the Finder
- From: "Mark J. Reed" <email@hidden>
- Date: Tue, 18 May 2010 08:31:51 -0400
An AS interface to a shell command like 'mdls' is basically a
nonsensical concept. There should be a native way of working with the
Spotlight system from AS, but that has nothing to do with the md*
commands, which are a way of working with that system from the shell.
in cases where no native AS interface exists,
The "do shell script" feature lets you use the shell interfaces from
AS, but it's necessarily awkward because it's translating a different
interaction style (e.g. In the shell, everything is just strings).
On Tuesday, May 18, 2010, Thomas Fischer <email@hidden> wrote:
> Hello,
> I used the various hints and now have a a version which pretty much does what I need.Alas, I can't copy it here as used because Mail will not accept ASCII 0, but I can use "character id 0":
> set myFile to choose fileset myInfo to do shell script "mdls -raw -name kMDItemCreator -name kMDItemEncodingApplications " & (quoted form of (POSIX path of myFile))set myInfo to change "[ \"\\(]*\\r[ \"\\)]*" into "" in myInfo with regexpset myInfo to change character id 0 into ", Producer: " in myInfotell application "Finder" to set comment of myFile to "Creator: " & myInfo
> This uses the Satimage Osax to search and replace text with regular expressions.In case anybody wonders: I want to make the creator of TeX-based PDF files visible in the Finder window as comments.Different creators/producers create different problems when trying to convert PDF to text, so that makes the differences easier to check.
>
>
> But I still find it– odd that there is information visible in the Finder's Info window that is not accessible using AppleScript and– awkward that there is no AppleScript interface to mdls, which returns a (sort of) record that can't be used as record in AppleScript.
> And its not really easy to get rid of superfluous quotes and to deal with Unicode (e.g. \U00A9) in the text either.I need now 27 lines of code to transform hexadecimal into decimal and another 13 lines to change \U00A9 into ©… Or ist there a simple way?
> Thanks to all!Thomas
>
> Am 18.05.2010 um 00:04 schrieb Luther Fuller:
> On May 17, 2010, at 4:25 PM, Thomas Fischer wrote:what I'm looking for is the data from:
> kMDItemCreator = \"ADOBEPS4.DRV Version 4.50\"andkMDItemEncodingApplications = ( \"Acrobat Distiller 5.0 (Windows)\")which is actually part of the information thatdo shell script "mdls " & (quoted form of (POSIX path of myFile))provides.But I still have to find an efficient way to get my hands on the parts.
> Here is the link to Apple's man page for 'mdls': http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man1/mdls.1.html
> Try using the -raw option. It may make getting your data easier.More likely than not, you will have to use AppleScript's text item delimiters to get exactly what you need for some data items.
> For example ...
> do shell script "mdls -raw -name kMDItemEncodingApplications " & (quoted form of (POSIX path of fileAlias))
> will give you just
> ( \"Acrobat Distiller 5.0 (Windows)\")
> from your example above. You will have to use ASTIDs to remove the unwanted leading and trailing characters.
>
>
--
Mark J. Reed <email@hidden>
_______________________________________________
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