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?


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".

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

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.


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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.