Page 1 of 1

Execute rules depending on which subfolder Hazel is in

PostPosted: Sat May 31, 2014 8:25 am
by pickyizzy
I have a folder structure that contains a top-level folder named Camera Uploads, with four subfolders (one for each of four iOS devices). The subfolder names are the names of each of the devices -- let's call them Device 1, Device 2, Device 3, and Device 4.

My question is "how do I create a rule (or a series of rules) at the Camera Uploads level that renames the files based which subfolder the files are in?" I am aware of the "How to get Hazel to go into subfolders" post, but I can't figure out how to make the subsequent "Rule1", "Rule 2"... do what I want (after the rule provided in the post). Here is what I envision Rule 1-Rule 4 doing:
1. If folder name is "Device 1" and kind is image or movie then rename file with "iPhone 5s" prefix
2. If folder name is "Device 2" and kind is image or movie then rename file with "iPad Air" prefix
3. If folder name is "Device 3" and kind is image or movie then rename file with "iPhone 5" prefix
4. If folder name is "Device 4" and kind is image or movie then rename file with "iPad mini" prefix

I understand Hazel enough that I am able to create four rules at the subfolder level, but I think that there is a better way to do this, incorporating the fact that Hazel can go into subfolders.

Re: Execute rules depending on which subfolder Hazel is in

PostPosted: Mon Jun 02, 2014 3:25 pm
by Mr_Noodle
If the folder name the same as the prefix you want to use? If so, you can do:

If (all) are met
If (all) are met for (the enclosing folder)
Name is (•folder name)
Do
Rename (•folder name) (name)...

To get the nested condition, hold down option while clicking the + button. The (•folder name) custom token is just comprised of (anything). What the above does is capture the folder name into (•folder name) and allows you to re-use it in the renaming pattern.

If the folder name does not line up with the prefix you want to use, you can try using the "Replace text" option to compensate.