Platypus Droplet Tutorial

This short tutorial will demonstrate the process of creating a Platypus droplet, i.e. a a Platypus script application that accepts dropped files as arguments.

Once you have selected your script and defined an Application name, you must click "Show advanced options" and check the "Is droppable" checkbox. This will tell Platypus to create an application bundle with an Info.plist file that tells the Finder (and, indeed, the whole OS) that it accepts dropped files. If you wish your droplet application to only accept dropped files of a certain kind, you can press the "Edit Types" button. This will display a window which allows you to fine-tune what kinds of files your application accepts by specifying suffixes and heritage 4-character File Types.

The files dropped on to your applications from the graphical user interface will now be passed on to your script via the ARGV array. However, the first argument in the ARGV array will always be the path to the application bundle itself (for example, /Applications/, so in most cases your script will only want to process files from the second argument and onwards. Below you'll see a sample Perl script that compresses the files it receives as argument using the gzip program:


$cnt = 0;

# loop through list of files dropped
if ($cnt != 0) # We ignore the first argument (the app bundle path)
# gzip each file in turn
system("gzip '$_'");

Of course, this little script just barely scratches the surface. The potential is astounding -- you can operate on the dropped files using all manner of command-line tools and programs, making dreary CLI commands as easy as dropping files on an app.