Create burnable folders anywhere

Automator is one of my favorite 10.4 features—it really does let nearly anyone create useful actions, even if you don’t know the first thing about programming. This recent article demonstrates exactly that fact, with five simple actions you can create yourself, just to get a feel for how Automator works.

But where Automator really shines is when you combine its relatively easy-to-use interface with its ability to directly access AppleScript and/or shell scripts through Automator actions—using this technique, you can access the full power of OS X through Automator’s interface. When you put that together with someone who can write some AppleScript or shell script code, you can really create some useful utilities…such as the one I’m about to discuss.

As a 10.4 user, you’re probably familiar with the Finder’s new burnable folders. This welcome addition to OS X means the end of lengthy file duplication when you want to burn a CD-R. Simply create a new burnable folder, the drag all the items into it that you want to put on the CD-R, and then click the Burn button. Instead of copying all the files, OS X just creates aliases in the burnable folder, and then resolves those to the actual data files when you click Burn. This is a much faster process than that of prior OS X releases. But it’s not perfect—what if you already have a folder full of stuff, ready to burn? It seems sort of pointless to create a new burnable folder and drag a bunch of aliases into it just to then burn that folder.

Well, it turns out that you don’t have to do this— any folder on your machine can be turned into a burnable folder, simply by adding the special .fpbf extension to its name. This being the user-friendly OS X, of course, you can’t simply do this from the Finder, as you’ll get a message stating that the extension is reserved for use by the system. If you’re wise with the ways of Terminal (/Applications/Utilities), you can avoid this problem—open a new Terminal window, move into the directory containing the folder you wish to make burnable (using the cd command), and then use the mv command to rename it:

mv "My Folder" "My Folder.fpbf"

When you press Return, you’re done—the “My Folder” folder is now burnable, and it will have the burnable folder icon in the Finder. In the Finder, click on the newly-burnable folder, click the Burn button, and you’re on your way to a really simple CD-R filled with that folder’s files. To reverse the burnable status of the folder, switch back to Terminal and issue the same command, but dropping the extension:

mv "My Folder.fpbf" "My Folder"

But don’t worry—today’s blog isn’t really about using Terminal to pull of this particular trick. It’s about using Automator, and not having to get your hands dirty while doing so! We’re going to create a Finder plug-in that will let you select one (or more) folders and toggle their burnable status via a simple contextual menu. Sounds like rocket science, but it’s really pretty simple.

Update: The following Automator workflow has been modified since this writeup was first published. I changed it from a one-step to a two-step workflow to avoid inconsistencies in its behvior in the Finder vs. in Automator itself (when testing).

Start by launching Automator, found in your Applications folder. We’re going to create a two-step Automator action. First click on the Finder entry in the Library column. Then find Get Selected Finder Items in the Action column, and drag it to the blank work area on the right side of the window. Next, select the Automator entry in the Library column, and then find and drag the Run Shell Script entry in the Action column into the work area on the right. Make sure you drop this Action below the one you’ve already placed. After you drop the Finder Action, click the Shell pop-up menu in its window, and make sure it’s set to /bin/bash. Also set the Pass input to pop-up to as arguments. This will ensure that the shell script you’re about to create runs correctly.

Now recall how I said that people with shell scripting skills can do some really amazing stuff? One such macosxhints reader, Alex Nicksay, posted a shell script on Macosxhints.com to handle this behind-the-scenes renaming of burnable folders. In the Run Shell Script area of your workflow, click in the script area (the spot that currently reads on run… ), and erase all that text. In its place, copy and paste this code:

	for i in "$@"; do if [ -d "$i" ]; then

i="${i%/}"; f="${i##*/}"; p="${i%/*}"
[[ "$f" = "$p" ]] && p="."
[[ $f == *.fpbf ]] && n="${f%.fpbf}" || n="$f.fpbf"
mv -v "$i" "$p/$n"
fi; done

Explaining exactly what this script does is well beyond the scope of this column (not to mention beyond the scope of my knowledge), but here’s a summary. Basically, the script looks at the Finder selection, and determines whether the selected folders are currently burnable or not. Whatever their current status, the script will then reverse those settings—burnable becomes non-burnable, and vice-versa. When you’ve got the script all set up, your workflow is complete, and it should look like the below image. I’ve hidden the Library and Action columns, so that there’s more room to show the work area, but note that the entire script doesn’t show in the screenshot, as that region isn’t resizable—just make sure your code matches what you see above, and you’ll be set…


To test your workflow, please follow these instructions, as you’ll want to be sure it’s functioning properly before using it on a ‘real’ folder. Leave Automator open, and switch to the Finder. Make a new folder, and then make sure it’s selected by clicking on it. Now switch back to your Automator action and click the Run button. When the workflow completes, you should hear a brief “wheeet” noise, and the lower right corner of the window should read “Workflow Execution Completed.” Switch back to the Finder, and look at the folder you just created—it should now be emblazoned with the Burn icon. Select it again, switch back to Automator, and run the workflow again. This time, when you switch back to the Finder, you should see that your test folder has returned to normal. If that’s not the case, then something’s wrong with the shell script step; compare your code to the snippet above, and make sure the two are identical.

Assuming everything worked with your test folder, you’re ready to make your workflow an easy-to-use contextual menu item. Switch back to Automator and select File: Save As Plug-In. In the Save Plug-in As box, give your new workflow a meaningful name, like Toggle Burnable or Toggle Burn Folder or somesuch. Make sure the Plug-in For pop-up says Finder, and then click Save.

Congratulations, you’ve just created a Finder plug-in to toggle the burnable status of any folder! To use your new action, click on any folder (or folders) in the Finder, and then control-click and select Automator: Burnable Toggle (or whatever you named the workflow). Presto, instant burnable folder. Repeat the process after you burn your CD-R, and the folder returns to normal. Didn’t I tell you Automator was amazingly useful?

Subscribe to the Best of Macworld Newsletter

Comments