Pepe
Pepe

Reputation: 1

Opening a file with an app using a command line in apple script or an automator app

I want to be able to double click to open a files type (HTML) in a particular app (SeaMonkey composer).

Double clicking the file opens SeaMonkey Browser, but I want it to open in Seamonkey Composer. The only way to do it is with the following command line

seamonkey -editor "filename.html"

So, how can I use apple script or automator to open my html files in composer ?

Upvotes: 0

Views: 1697

Answers (2)

foo
foo

Reputation: 724

Save the following script as Application in Script Editor:

on run filesList
    repeat with fileRef in filesList
        do shell script "seamonkey -editor " & quoted form of POSIX path of fileRef
    end repeat
end run

Select View > Show Bundle Contents and give it a custom bundle ID. You can then change the file association as above.

The above assumes the seamonkey command is itself just a launcher; if it's actually the full application (which may be the case as it's obviously not a native Mac app), the middle line'll need tweaked a bit:

do shell script "nohup seamonkey -editor " & quoted form of POSIX path of fileRef & " >/dev/null 2>&1"

That should allow the shell script to exit as soon as the seamonkey process is launched, leaving Seamonkey running until you quit it from its GUI.

Upvotes: 1

JMichaelTX
JMichaelTX

Reputation: 1807

If you want to use AppleScript to do this, this simple script should do the job:

set filePath to ((path to documents folder) as text) & "filename.html"
tell application "Seamonkey Composer" to open filePath

I don't have the Seamonkey Composer app to test, but it works with BBEdit. Note that the open command must have a full path to the file.

Upvotes: 0

Related Questions