HACK / MAKE

Mac Brain: Managing Files with Hazel

This post is part of a series on setting up a Mac server and automation system to simplify computing and take greater advantage of iOS devices. You can read all of the posts from my Mac Brain project here.

One of the main goals of setting up an automated Mac was to relieve constraints in iOS and the iPad. One of those that has always been a challenge is managing files. A file system doesn’t really exist on the iOS (though you could argue that Dropbox has mostly filled that gap) and it’s relatively small drive isn’t ideal for long-term file storage. iCloud and Dropbox have stepped up to solve many of these issues for normal iPad users but for someone like myself, who wants to make the iPad my main device, there are concerns about putting my trust in the cloud.

There were two main categories of files I wanted to handle using my iPad: things I wanted constant and current access to and stuff I have to collect and wanted to archive. The stuff I wanted access to are things like my plain-text notes and photos and the things I needed to collect then archive are things like bank statements that would come in and be processed and working files that I no longer need immediate access to. I used to keep all of my documents in Dropbox but I recently realized that I didn’t need anytime-access to most of them on any device. What I lost by moving them out of Dropbox I gained by not having a lot of personal files in a more likely to be compromised system. Now things that don’t need to be in the cloud aren’t. They’re safely and obsessively organized on my Mac. This isn’t anything new, most of you have files archived on your machines, but the nice thing for me is that this isn’t a day-to-day used computer so I don’t notice files piling up in Finder. The beauty of this system is that I can set it up to organize my files the way that I want and then I never have to worry about it or even see the files.

Archive and Document Folder Structure

When I was first setting up this server, I spent some time in Finder organizing what documents and random files I had around into two main places: an Archive folder, and the standard ~/Documents folder. Into Archive, I moved a bunch of files from my Dropbox into a /YYYY/MM_Month/ folder structure based on the created date of the file and made a couple Smart Folders to more easily find old archived PDFs and images. Into ~/Documents go some more current and specific files that don’t quite fit into a ‘junk drawer’ archive, but should be more cleanly organized. Right now, this is where I put bank statements.

Both of these endpoints have the same in-point. It’s a folder on my Dropbox named [DROP]. In this folder, I can drop a whole range of files and based on Hazel rules I set up, my filing will happen automatically. Archival into my /YYYY/MM_Month/ directories will happen whenever I drop files into a [To Archive] folder in that drop folder. With this system, I can pass pretty much any file type on the iPad to “Open in Dropbox” where I’ll be prompted to choose a folder to put it in. Choosing [DROP] will sync the file over to my Mac brain and Hazel will do what I ask of it.

Let’s go through a couple of the Hazel rules as examples and so your imaginations can be piqued as to what kind of things you’ll be able to do to automate your system. This will be more of the methods and thought process of working with Hazel since setting up the tasks are pretty straightforward.

PDFs: From iPad to Archive

Bank statements were never really something that were too important to me because I figured that I’d just always be able to get them from my bank’s website. A few months ago, my Mom asked me for record or some payment stuff from years ago for something legal or tax related. I went to my bank and realized that they only kept my statements from within 18 months. At this point I figured it would be worth holding onto them on my side but until I set up this machine, I didn’t really keep up with it because of the nuisance of pulling down and organizing the files.1 With Hazel, I just need to get the file into my [DROP] folder and it’ll do the rest. To set this up, I pulled down the PDFs from my banks site and looked to make sure I could find a consistent pattern in the file name that I could tell Hazel to look for. All four of my banking related service providers named the PDF statements in a way that Hazel could uniquely recognize. So with Hazel matching the filename containing ‘eStatement’ and extension is ‘.pdf’ in my [DROP] folder, it’ll rename the PDF to something like BANKNAME_CHECKING_2012-09.pdf and move it into the folder ~/Documents/Bank Name/Checking/YYYY/, again all based on the rules I set up. I also have it importing those documents into Evernote. Doing both isn’t necessary but I wasn’t totally sure which system I wanted for this type of document archival, so I went with both for now. In the last step of the Hazel task, I use this Applescript to get the document into Evernote:

set m to do shell script "date +'%m'"
set y to do shell script "date +'%Y'"

tell application "Evernote" activate
    create note title "Name of Bank Checking Statement for " & y & "-" & m notebook "Bank Statements" from file theFile
end tell

In the end, your task will look something like this.

Organizing Your Plain-text Notes

Another way I use Hazel is to keep my plain-text notes folder clean. Some people just leave everything in this folder whether they’ll need it again or not, but I want to keep it clean. I have both scratchpads and reports I create from my analytics tracker, Gaug.es, go into my Notes directory but I only really need immediate access to these within the week they are created. Once they get over a week old, Hazel moves them into a sub-folder in /Notes so I still have access to them, but they aren’t clogging up my main list. The Hazel rule for this is basic: if it matches my Scratchpad_YYYY-MM-DD file naming convention and the Date Created is not This Week, then it gets dumped into a /Scratchpad/YYYY/MM_Month/ folder. Now these files are still easily accessible but they also aren’t in the way when I’m searching through my notes on Notesy for iPad.

I want to be getting deeper into using Hazel to help organize my life. If you have some interesting Hazel jobs, I’d love to hear about them (I’m @nickwynja on Twitter). What I’ve got so far is pretty basic but has helped simplify and keep me organized while using iPad.


  1. Watch for an upcoming post about Mail.app rules to see how I set up the automatic creation of OmniFocus tasks to tell me to review and archive my bank statements whenever my bank sends me an email to let me know the new document is up. 

Thoughts or comments? Let's talk on Twitter or send me an email.