Walk subfolders, handle content and delete empty folders

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

Moderator: Mr_Noodle

As far as I understand, only the first rule that matches will be executed, but how can I solve the following:
(1) Walk down Folders .. Subfolders .. Subsubfolders .....
(2) If it contains files with the extension *.doc move to folder /Documents
(3) If there was a .doc in this folder (moved by rule 2) and now it is empty or has other files -> delete

Maybe I could start with
Type Folder, Size > 0B ==> Apply rules
Extension .doc ==> move to documents
Type Folder, Size = 0B ==> delete

But these rules will not meet my scenario.
Thanks in advance
nwehrle
 
Posts: 4
Joined: Sun Apr 15, 2012 4:05 pm

Just stick the rule to match empty folders first. It is more specific than the rule to go into subfolders so it will match the empty folders. Non-empty folders will not match it so it moves on to the next rule which matches any folder.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Thank you. I guess, I have to play with hazel a lot to ask more detailed questions.
One question that would help: What triggers the rules?

Example:
10:00:00 Folder "docs" created
10:00:15 File "example.doc" is copied to folder "docs"

If my first rule would be to "delete empty folders", will I ever have the possibility to create folders inside a watched folder to copy files into? Is it possible to extract archives in that folder without matching the "delete empty folder" - rule? Do you have a safety timeout or do I have to configure a safety timout in my rules?
nwehrle
 
Posts: 4
Joined: Sun Apr 15, 2012 4:05 pm

Is there a reason to create the folder ahead of time? Why not use the "Sort into subfolder" action to create it for you on the fly?

If you really need for Hazel not to touch in for a while, add a condition like "date last modified is not in the last 15 minutes".
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Yes there is a reason - the folders (and the files inside) are generated by a workflow tool using the export-menu.

(1) Lets come back to this question: What triggers the evaluation of hazel rules?
[ ] a new file/folder
[ ] a changed file
[ ] a meta-data update
[ ] time-trigger
[ ] ...

(2) If I have a watched folder and rules have run automatically: delete some files, move some files, mark some files ... will the rules run a second time without a change in that watched folder? When? Why?
The reason for that question is to clean up in a second run what the first run left.

Thanks for your patience.
nwehrle
 
Posts: 4
Joined: Sun Apr 15, 2012 4:05 pm

Any file events plus timed events will trigger Hazel. If your rules have modified anything, Hazel will go back for another pass. Basically, it will keep going until things are stable.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support