Helpful Automator Workflows for Developers
I love OS X. For me, it’s the ideal development platform. I primarily build web applications that run on the LAMP stack, so having a POSIX compliant UNIX like OS for my daily driver is extremely convenient. My development environment works just like the environments I deploy to, so I don’t have to worry very much about platform inconsistencies. OS X is the perfect balance of elegance and power. I only wish Finder didn’t suck so hard.
There are some actions I need to perform on files on a regular basis that are not supported in Finder. For example, recursively deleting files in a tree of directories, but leaving the directory structure intact. I have a code generation tool that scaffolds out a boatload of PHP classes based on MySQL database. During heavy development, I need to blow away the files on a regular basis without deleting the output directories. Finder simply cannot do this. Luckily Apple has provided a way to add Automator actions to the context menu in Finder. I put together a simple workflow to recursively delete files in a tree of folders, here is is for your convenience:
DeleteFolderContents.zip – MD5: 5d0ad832e9e998dbefd70d49f2a07b52
Unzip, and copy the workflow file to Library/Workflow/Applications/Finder/ in your home directory. If all has gone well, you should have a new option in the context menu when you right-click a folder in Finder:
Another Finder deficiency that was bugging Jon recently is the inability to copy the filesystem path of a folder in Finder to your clipboard. I put together a little workflow that does just that:
CopyPathToClipboard.zip – MD5: b64558cf3afb7aecdec63faccb5986ba
Follow the same steps outlined above to copy the workflow to the proper location.
Note that these workflows are compatible with OS X version 10.5, and will not run in Automator on 10.4 or previous systems.