4

I'm trying to figure out if it's possible to program the open action (double clicking on a file) for a given file extension in OS X as:

Pass the file's absolute path to a shell script (bash or ruby or python preferably).

The only solution I'm arriving at is packaging my script as an app and setting the filetype association to always open extension .xyz in my app. Is there an easier way?

4 Answers 4

1

The only way is to package the script as an app.

For portability, you can simply create an AppleScript container that will execute the shell script you created.

Check out do shell script for more information.

When you go to save the script, be sure to save it as an "Application" or "Application Bundle".

2
  • good call, didn't think of that. i think this'll work for now. Jul 23, 2009 at 21:37
  • oh, one other thing: know how to grab the path of the file that was opened in the applescript app? Jul 23, 2009 at 21:51
5

I had tons of problems with the pure-AppleScript approach. Then I found Platypus - it had me up and running in less than 5 minutes.

0

You should be able to right click a file and "Get Info". Under "Open with" you can select the script you want to open the filetype with and also check the "Change All" button.

This should change the filetype to open with your script.

2
  • I realize that's how you normally change associations with apps Jul 23, 2009 at 21:15
  • but it doesn't work with scripts. Only fully packaged apps. Jul 23, 2009 at 21:15
0
  • Right-click on a file of the file type in question;
  • Go to "open with";
  • Pick the program;
  • And then click "Change All.."

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .