------------------------------------------------------------------------ --
#!/usr/bin/perl
my $file = shift or die "No file specified";
use File::Spec; $file = File::Spec->rel2abs($file) if !File::Spec->file_name_is_absolute($file);
system(qq{osascript -e 'tell application "Finder" to reveal "$file" as POSIX file as alias'});
system(qq{osascript -e 'tell application "Finder" to activate'});
------------------------------------------------------------------------ --
I save it as ~/bin/select, and now I can just do 'select Perl.tar' and I see the icon in the Finder. =)
-Ken
On Wednesday, February 26, 2003, at 10:28 AM, Ted Brown wrote:
You're passing a unix path, and by default, the Finder doesn't know what to do with it.
Here's the syntax from a test in the Script Editor that works: reveal "/Users/ken/Perl.tar" as POSIX file as alias
Try:
osascript -e 'tell application "Finder" to reveal "/Users/ken/Perl.tar" as POSIX file as alias'
And that's a good trick. Wish I'd thought of it. :-)
(I'm at work, so I can't mail the list, if you want to pass this on, feel free.)
On Wednesday, February 26, 2003, at 10:57 AM, Ken Williams wrote:
Hi,
The osascript example in a recent thread gave me an idea - I'd like a shell command that would tell the Finder to reveal the item with a certain path, something like this:
% osascript -e 'tell application "Finder" to reveal file "/Users/ken/Perl.tar"'
This would be useful (if it worked) for initiating drag-n-drop operations, getting finder info, looking at the preview icon, etc.
I've tried several variations on the above theme, but none of them work. My Applescript-Fu is not strong. For instance, the above gives me the error:
execution error: Finder got an error: Can't get file "/Users/ken/Perl.tar". (-1728)
If I dig around in the applescript dictionary for the Finder, I find a 'name' property, but that doesn't seem to get me much farther:
% osascript -e 'tell application "Finder" to reveal file name "/Users/ken/Perl.tar"'
syntax error: Invalid key form. (-10002)
Anyone?
-Ken