Launching a local file in the default browser

Ken Ray kray at sonsothunder.com
Mon Aug 18 15:57:01 EDT 2003


Hugh,

You do this applescript:

tell application "Finder"
  open file <filePath>
end tell

Works like a charm (but remember you need to have ":"-delimited paths).

Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/ 

-----Original Message-----
From: metacard-admin at lists.runrev.com
[mailto:metacard-admin at lists.runrev.com] On Behalf Of
FlexibleLearning at aol.com
Sent: Monday, August 18, 2003 2:32 PM
To: metacard at lists.runrev.com
Subject: RE: Launching a local file in the default browser


The Original:

     <send "file:///" &tPath to program "Finder" with "GURLGURL">

Ken wrote:

> I tried it without the "file:///" in OS X as well as with other
> variations with less than three slashes. All did nothing. Perhaps it's
> the fact they are "/"-delimited paths that they require "file:///" ? 


As Brian points out, the third / is the first character of the Mac
path...

     send "file://" & "/Alice/Desktop Folder/myGif.gif" to program
"Finder" with "GURLGURL"

should happily attempt to open the file in the default Browser. This is
fine, so long as the Browser can display the filePath like images and
simple text. But... What's the syntax to open ANY file with it's native
application when you don't know the filetype-creator? It must be
possible as the Finder does it when you double-click an icon on the
desktop. I'm sure that sending the appropriate AppleScript to Finder
would do the trick, as in...

     put "send open file"&&tURL&& "to Finder" into tScript
     do tScript as AppleScript
     put the result

(okay, this puts "compiler error", but that's because I don't know
AppleScript!)

I suspect there will be syntax differences between MacOS and OSX
(perhaps "file" vs "location")

Any offerings? Still much needed here! 

/H 





More information about the metacard mailing list