Bottom Line: You can use AppleScript Editor to test your AppleScripts destined for Hazel with this little trick.

I frequently post about Hazel and the hundreds of menial, repetitive tasks I can get it to take care of for me (see my posts tagged “automation”). Although it has a great GUI interface for getting some serious work done, I often end up embedding a little AppleScript or shell script.

Because Hazel’s job is to act when it notices a new file in a folder it’s set to monitor, it can be a little frustrating testing and debugging these AppleScripts as I write them. It’s smart enough to not run multiple times on the same file (unless the file changes), but this ends up being a problem when it comes to testing. You drop the file in the folder, the script doesn’t run correctly, then you have to drag it out of the folder and back in again for the next round of testing. Lame, especially or a keyboard navigation junkie like me.

However, I’ve found a little trick that really speeds things up. You might have noticed that Hazel likes to refer to the file being processed as “theFile.” Well, you can just add an alias “theFile” to the top of the script and it will run in AppleScript Editor just like in Hazel, which means you can just command + R to run it, tweak more, and repeat, no mousing around or GUI moving files necessary.

As I’ve tried to indicate, you can just use the “property theFile” part for testing a script that will be embedded in Hazel (delete or comment the rest), or include the whole hazelprocessfile jazz for testing external scripts that Hazel will reference. Just uncomment the relevant parts and test away. The fully commented script, as you see it now, is how it should look after testing, when it’s ready for prime-time. (I recommend you keep the parts commented out instead of erasing them in case you need to test more in the future.)