Re: Finder Show Info Comments
Re: Finder Show Info Comments
- Subject: Re: Finder Show Info Comments
- From: Greg Titus <email@hidden>
- Date: Thu, 6 Dec 2001 10:27:34 -0800
On Thursday, December 6, 2001, at 07:59 AM, Eric Schlegel wrote:
On Wednesday, December 5, 2001, at 10:53 PM, Ian G. Gillespie wrote:
I am trying to figure out how I can get a string out of the comments
text view in Finder's Show Info Window. I would also like to be able
edit the string and then put it back. Anyone know how I can do this
preferably using Java?
You need to use the Finder's AppleEvent suite to do that. The old
desktop database APIs are implemented in Carbon, but the Mac OS X
Finder doesn't store comments in the desktop database, so using those
APIs won't help.
There's no Java binding, but if you have OmniAppKit (see developer
section of www.omnigroup.com) around you could do:
scriptText = [NSString stringWithFormat:@"tell application \"Finder\" to
get comment of file \"%@\"", hfsPath];
comment = [OAAppleScript executeScriptString:scriptText];
// modify comment as desired here
scriptText = [NSString stringWithFormat:@"tell application \"Finder\" to
set comment of file \"%@\" to \"%@\"", hfsPath, comment];
[OAAppleScript executeScriptString:scriptText];
Also note that Finder expects your path to be colon separated, Carbon
style, not slash separated, Unix style.
A quick way to change is:
fileURL = CFURLCreateWithFileSystemPath(NULL, (CFStringRef)filename,
kCFURLPOSIXPathStyle, NO);
hfsPath = (NSString *)CFURLCopyFileSystemPath(fileURL,
kCFURLHFSPathStyle);
CFRelease(fileURL);
Hope this helps,
--Greg