Recursive THEN non-recursive operation possible?

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

First, yes, I read the manual on handling subfolders, ran previews, and reviewed logs in debug mode. :wink:

Second, I have lots of rules and consider myself quite experienced with Hazel, but this one is getting me.

Third,
Code: Select all
5.3.4 (2388)


A very simple 3-step workflow:

1. Trash all files with extension .abc (very large files)
2. "Go Into Subfolders" (Do step one recursively)
3. Move the top-level folder (depth-0) to a network drive.

I can get steps 1 and 2 to work OR I can get step 3 to work, but not both. The difference? Adding "Continue Matching Rules" to step 2.

  • If I don't add "Continue Matching Rules," then step 3 never runs, which totally makes sense.
  • If I do add "Continue Matching Rules," then rules 1 and 2 never run, which doesn't really make sense to me.


I've tried everything I can think of:

  • Switched the order of "Continue Matching" and "Run Rules on Folder Contents" within step 2.
  • Swapped the order of step 2 to the other positions.
  • Added "Run Rules on Folder Contents" to step 3, prior to the "Move" operation.
  • Did some testing with "Copy Folder Structure" but couldn't get the right results.

Screenshots:

Image Image Image

Thank you in advance for your help!
send_noods
 
Posts: 2
Joined: Tue Apr 22, 2025 1:07 am

I think the problem is that it does not go into the subfolder until it finishes processing everything in the current folder. So it ends up moving the folder before going into it.

You should add conditions to the "Move to Storage" rule to only run after the def files are moved out. You can use a nested condition to see if the folder contains any def files below it.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

I was unable to resolve this issue in the manner I originally intended. However, I did manage to resolve it by only moving the filetypes I was interested in, and using the "copy folder structure" option. Then I just trashed everything else.

Pro Tip:

As a side note to future readers, I know it can be confusing to know what order all the files are processed in, and unfortunately the preview option doesn't really help you get a good understanding of it. (Something more akin to --dry-run would be super awesome!). What I found to be helpful is using "Add Tags" at the start of each set of actions, and "Remove tags" at the end. This way there is always a little orange dot next to file/folder being processed so you can visually see the order it takes as it traverses hierarchies. This really helped me better understand what the rules are doing, and might help you with whatever challenges you're facing.
send_noods
 
Posts: 2
Joined: Tue Apr 22, 2025 1:07 am


Return to Support