Automatically Create a Specific Folder Structure with Automator & Hazel

Here’s a handy method using Automator and Hazel to automatically create a specific folder structure within a folder. I use this for client projects, since they are always the same. With this setup, I just add a new folder to my “Clients” folder, and all the standard sub-folders I need added are auto-created by Hazel, via Automator. 

The Hazel rule would be something like:

and here is the setup for the Automator Service:

If I recall correctly, you need to manually create a new variable (in this case “Current Folder” but can be named whatever you like). Repeat the bottom action as many times as you need for other folders, changing the name of course.

I made it a service so I can access it manually if need be.


15 thoughts on “Automatically Create a Specific Folder Structure with Automator & Hazel

  1. I had a few minutes and was reading this and it is cool but thought the same thing could be accomplished in the finder quite easily. If you set up the structure you want some where on your drive you can just copy the root folder and paste it in where you want and the entire structure is replicated. For Example I set up a folder Templates and in there created a sub folder Testa and then in there testb and then in there testc. I then went to the testa folder and copied it. Went to the documents and pasted it, the entire structure is replicated. Ie now under documents there is Testa is there testb is in there and in it is testc. Is this not the same as what are doing or am I missing something. Cool way to learn more about hazel though.

    1. Indeed you could do this the way you mentioned. But that requires navigating to the folder where you stored the template, option-dragging to the new location, multiple Finder windows, etc. With my method, when I create a new project folder, it all happens automatically. If you haven’t noticed, I love automating stuff on the Mac :)

  2. I saw this one on the Hazel forums also, and have put the same question on the forums over there:

    It might be my ignorance, is this rule supposed to create the subfolders in the folder Hazel is watching, or within the folder created? I have tried to duplicate the rule and it keeps creating the subfolders in the folder Hazel is watching, not in the folder created.

    I’d appreciate any help/info you could provide.

    1. This rule watches for new folders in the watched folder, and then creates subfolders within any new folders meeting the criteria.

      Hazel watches “Watched Folder”; if I add “Subfolder 1” to the “Watched Folder”, Hazel will create the new folders within “Subfolder 1”. Hope that helps.

  3. Very useful, thank you!
    Now my big question is, I want to create several folders (manually) like Job_01 … etc with subfolders in them, lets say “Filetype_A” and “Filetype_B” thats perfectly done with your description.

    Now I will import files, I want to distribute between those two, seperated by filetype, but as every import has a different enclosing folder (job_02 job_03 etc) right now I am copying the rule to move the files in hazel, but then have to modify every rule manually to make the files to go to job_02 > Filetype_A
    if I forget to do that the files end up in the wrong job folder … anyway its not satisfying yet.

    Do you have any idea? This would make my workflow so much more effective


    1. just to be clear:
      right now I drop all files in eg Filetype_B in the right job folder, but then

      I have to modify every rule manually to make the files go to
      job_02 > Filetype_A,
      job_03 > Filetype_A
      job_04 > etc

    2. If I am understanding you properly , you should be able to do this by setting up the rule so it matches a folder name pattern, instead of matching the name exactly.

      The rule pattern might be:

      Name matches “Job_(number)”

      Where the info in parentheses is the match token in Hazel. This prevents false matches (it only matches folders that have names starting with “Job_” but allows for variations.

  4. Hi George, This looks very nice.. If I had a say 4-5 deep folder structure within one master folder, and I wanted to move all of the files whose names contained _adk_ for example to an already existing identical folder structure in a different location, could I adapt your script here to do that?

    1. This uses Automator, and not a script. But either way, it’s for creating blank folder structures and not copying files. I think you can just use Hazel’s built-in “Copy” functionality, which now includes options to retain existing folder structures. I’ve never used those options though so I am not exactly sure how they work. But it sounds like it’s exactly what you want.

      If not, try asking your question over at the Hazel forums, lots of helpful users there including the developer.

    1. Thank you, yeah since I posted this I’ve discovered simpler methods to do this. the Automator methods is nice for non-coders just getting into automation, but yeah shell scripts are the way to go. I’m not much of a coder so I rely on Frankensteining together code I find online.

  5. Hey George,

    Thank you so much for writing this guide! I’m trying to replicate it to archive payment receipts every month into a new folder with the month’s name (eg. 2017-10), however I can’t get the Automator service to work. Is there a change in High Sierra?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s