Page 1 of 1

Run rules on folder contents but only for some rules?

PostPosted: Wed Sep 01, 2021 3:56 am
by PaddyPatPat
Hi there,

I use tagging to control the flow of new files from the desktop into my client and project folder hierarchy. I have a "Work" folder that does the majority of the filtering of files into different client folders. Client folders (and some subfolders) then also have more rules as required. it's done a great job for years now. Thank you.

These files consume 100s of GBs of space. So I've started archiving them to an external drive to leave more room on my main drive. This archive is a complete copy and what I will always go back to when I need to resurrect details from a previous instance of a project. My main hard drive now just contains the projects I've been working with recently. I've only just built the Hazel rules to look after this, tested with 10s of GBs of files and it all looks to be working well.

The next step is to combine the two, but I'm not sure what's the best method of doing this.

Philosophically, the tagging actions should happen first, putting files into their correct folder. Then, use the rules that push the newly used files into the Archive. These are just a "Copy" rule combined with a separate "Run rules on folder contents" rule. Adding these two rules to the bottom of the "Work" folder seems like a bad idea because it will apply the "Run rules on folder contents" rule to all my tagging rules. If I put the "Copy" and "Run rules on folder contents" (RROFC) above the tagging rules, then the tagging rules won't be affected by the "RROFC" rule, but the files won't be in their correct home either.

I'm keen for any suggestions anyone has.

Thank you for your time.


Re: Run rules on folder contents but only for some rules?

PostPosted: Wed Sep 01, 2021 10:12 am
by Mr_Noodle
Do you want to archive stuff on a file-by-file basis or does it make more sense to do it on a client basis? Are you archiving by date or by some other metric?

Re: Run rules on folder contents but only for some rules?

PostPosted: Wed Sep 01, 2021 6:20 pm
by PaddyPatPat
I wish to archive on a folder by folder basis.
I work for lots of clients at once, each getting different days but with me prepping for them beforehand as makes sense as information comes in. At any time I want to have files from about 4 of the 12+ clients.
Of each client, I only want access to the projects that are currently active for that client.
Within client folders, there are perhaps up to three levels of filing, usually based on a project tag, and then by year, and perhaps month, with a "Sort into subfolder" action. Sorting within client folders is all done with rules applied to the client folder itself.

In terms of the interaction between the Main Drive "Work" folder and the External drive Archive folder, the way I've done this is...

To copy from my External Drive "Archive" ("Files accessed within the last 3 months"):

    - All are met:
      - Kind is not a folder
      - Tags do not contain "not_needed"
      - All are met for any file or folder in the same folder
        - Kind is not a folder
        - Date last opened is in the last 13 weeks
    Do the following:
      - Copy to Main Drive "Work" folder. If the file exists, do not copy the file. Do not copy if a duplicate. Copy folder structure from monitored folder.

And then combined this with a separate "Run rules on folder contents" that is applied to folders.

From my Main Drive "Work" folder to my External Drive "Archive" folder, I use a Copy rule ("Copy files to Archive"):

    All are met:
      - Kind is not a folder.
      - Date last opened is after Date last modified.
    Do the following:
      Copy to Archive folder. If the file exists, replace the existing file. Copy folder structure from monitored folder.

... with a Delete rule.... ("Delete files no longer needed")

    - Any are met:
      - All are met:
        - Kind is not a folder.
        - Tags do not contain "Needed".
        - Any are met for all files and folders in the same folder.
          - Date Last Opened is not in the last 14 weeks.
      - Any are met for the current file or folder:
        Tags contain "Not_needed"
    Do the following:
      Move to the trash.

And then added the "Run rules on folder contents" to the end of this rule set.
As I said previously, this Main Drive "Work" folder is currently the host of the bunch of rules that move files based on tag into the correct client folder.

The one thought I just had is that I could move all of those rules that move files into the correct client folder by tag to instead to applied from the "Desktop" folder. This would mean that they would by-pass the "Work" folder and so not interact with the "Run rules on folder contents" rule. It would be slightly messier for the rules in the "Desktop" folder but the Hazel 5 folder groups are helpful for this. One thing I have done so far is to tag folders with everything but "Work" while they have still been on the Desktop when I wasn't ready to move them. This meant they still reacted to searches by tag properly but wouldn't trigger Hazel to move them into the client folder before I was ready. I could still do this but just adjust the client rules so that they had to have this tag as a requirement.

That's my best guess for a solution. Any other suggestions, even generally for ways to improve things?

While I'm on a run, and have my workflow documented here, one thing I would love to be able to do is set up one rule and fed it a list of tags it should watch for, filing matching files into the correspondingly named folder. This would save having so many rules all doing the same thing for different tags.

Re: Run rules on folder contents but only for some rules?

PostPosted: Fri Sep 03, 2021 4:41 pm
by Mr_Noodle
I'm a bit lost in all this as I don't know why there are rules in the archive copying files back. It's still not clear to me why you are copying individual files. It seems like you want to archive things on a project basis? If so, you should consider having your rule match the project folder and copy/move that as needed.