Re: Getting Info from the Finder
Re: Getting Info from the Finder
- Subject: Re: Getting Info from the Finder
- From: Thomas Fischer <email@hidden>
- Date: Tue, 18 May 2010 13:34:09 +0200
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 file set 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 regexp set myInfo to change character id 0 into ", Producer: " in myInfo tell 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\" and kMDItemEncodingApplications = ( \"Acrobat Distiller 5.0 (Windows)\" ) which is actually part of the information that do 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.
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.
|
_______________________________________________
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