MacOS – How to make a bash script so that I can drag its input on top of the icon

automationbashcommand linemacosterminal

I need to make a bash script to that I can drag a .rar file on top of it and then the script will receive the pathname of that file as argument 1 ($1).

I have made the bash script, but how do I make it to be an application (right now MAC OSX is treating it as a text file even though I did chmod +x) and how do I enable the drag and drop way of sending a file to my script?

Best Answer

You should be able to turn your script into an application with Automator - Applications -> Utilities -> Automator.app. Look for an option called "Run Shell Script" and once you're done, it should behave like other apps in that anything that is dragged and dropped on it will be run with it. Good luck!