Page 1 of 1

Rename folder when new file is added/deleted

PostPosted: Tue Nov 01, 2022 10:46 am
by Danny Wyatt
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?

Re: Rename folder when new file is added/deleted

PostPosted: Wed Nov 02, 2022 9:15 am
by Mr_Noodle
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.

Re: Rename folder when new file is added/deleted

PostPosted: Wed Nov 02, 2022 11:21 am
by Danny Wyatt
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?

Re: Rename folder when new file is added/deleted

PostPosted: Thu Nov 03, 2022 10:03 am
by Mr_Noodle
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?

Re: Rename folder when new file is added/deleted

PostPosted: Thu Nov 03, 2022 10:56 am
by Danny Wyatt
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.

Re: Rename folder when new file is added/deleted

PostPosted: Thu Nov 03, 2022 11:03 am
by Danny Wyatt
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

Re: Rename folder when new file is added/deleted

PostPosted: Mon Nov 07, 2022 10:18 am
by Mr_Noodle
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.