Rename folder when new file is added/deleted

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

Moderator: Mr_Noodle

I have a folder called "Work - 0"
Now every time I add a new file/folder to that folder, I would like it to be renamed and instead of 0, it would show the number of files inside that folder, so if I drop 4 files there, it would then become "Work - 4". If I then delete 2 files, it renames it "Work - 2".
It would only read "sub" files/folder, not sub sub files/folders. So if I have 2 folders inside with 30 files inside each, it would still just rename it "Work - 2", not "Work - 62"

Is this possible?
I would assume it's not, because that would create a conflict with the folder's name inside Hazel, but maybe I'm not aware of other "tricks" to achieve this?
Danny Wyatt
 
Posts: 25
Joined: Wed Mar 23, 2022 7:39 am

You would need to monitor the folder that contains the "Work - " folder. Set up the conditions to match that folder and in the Rename pattern, drag in the "Other" attribute. From there, you should see "Number of items" which should be what you want here.
Mr_Noodle
Site Admin
 
Posts: 11240
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:You would need to monitor the folder that contains the "Work - " folder. Set up the conditions to match that folder and in the Rename pattern, drag in the "Other" attribute. From there, you should see "Number of items" which should be what you want here.


This is what I did:
Image

And I can run it once, it renames it (with the wrong number, actually), but then if I add more items or remove them, nothing happens:
Image
I have 2 items, but it renamed it adding "3" instead of 2

Am I missing something?
If so, can you please share how the rule should be?
Danny Wyatt
 
Posts: 25
Joined: Wed Mar 23, 2022 7:39 am

First off, you may want to add a condition to tell it to re-match if things change. You can try "Date modified is after date last matched". Otherwise, it will only match the first time.

As for the number being off, I'm wondering if that's because of hidden files in the folder. Are you comfortable using the commandline?
Mr_Noodle
Site Admin
 
Posts: 11240
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:First off, you may want to add a condition to tell it to re-match if things change. You can try "Date modified is after date last matched". Otherwise, it will only match the first time.

As for the number being off, I'm wondering if that's because of hidden files in the folder. Are you comfortable using the commandline?


Unfortunately, still not working (check the original time 2:37):
Image

And these are the rules:
Image

I added a different rule just for testing purposes and it worked. It was just a separate rule to add a Red tag.
So the issue seems to be with this rule.

Regarding the hidden files, there are no hidden files there. Using SHIFT+CMD+. shows/hides the files and there's none.
Danny Wyatt
 
Posts: 25
Joined: Wed Mar 23, 2022 7:39 am

Ok I did some testing and here's what I noticed:
If I remove the Work folder from the Test folder (which is the one being monitored) and then move it back to Test, it seems to work, so it seems that the rule is monitoring the date of the Test folder, not the Work folder. Problem is changing the content inside the Work folder, doesn't change the Date Modified for Test folder.

Image
Danny Wyatt
 
Posts: 25
Joined: Wed Mar 23, 2022 7:39 am

Rules do not apply to the monitored folder. Adding the Work folder to the test folder works because it is the first time it appears which is a file change which can be noticed.

Please go through the troubleshooting guide here: https://www.noodlesoft.com/kb/hazel-tro ... ing-guide/

Report back with results from every test noted there.
Mr_Noodle
Site Admin
 
Posts: 11240
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support

cron