Match folder name to current date as condition

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

Moderator: Mr_Noodle

Hey,

I have been reading the manual, looking at the test rules, and searching this forum for something that I think should be easy (and feel like a total newbie for having to ask):

Is there a way in which I can set as a condition that a folder name should match today's date, before its contents is processed?

My use case, in a nutshell: I have digital tickler files, and want to move – every morning of every day - all documents in the tickler folder that matches today's date to my inbox folder. For example, tomorrow morning I want all files that reside in the folder 20190108 to be moved out of that folder into my inbox folder. The tricky part: these files could have been moved any day into that folder: today, last week, three weeks ago, half a year ago. So none of the date options – date created, date last modified, date last opened, date last matched - helps, it seems to me at least (after trying them all out).

All I would need is a condition along the lines of "Kind is folder" and "Name of the folder matches today's date (in a specific format)". And for the life of me I cannot figure this out…

Any pointers, hopefully not too embarrassing?
nonformality
 
Posts: 2
Joined: Mon Jan 07, 2019 11:09 am

Check the chapter on match patterns in the help. You can use a custom date attribute. That date attribute can then be used on the left hand side of a condition so you can do "<the date attribute> is Today". You can then do "Run rules on folder contents" to have Hazel go into that folder. You would then need more rules to process the files inside.
Mr_Noodle
Site Admin
 
Posts: 8363
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Thank you! That helped, and I got it to work.

One related question for understanding: the format of Today () is always YYYYMMDD? Or can that somehow be influenced? So far, I can only get it to work with that exact pattern – which is not a problem, it's just out of curiosity (and because it has an influence on my workflow).
nonformality
 
Posts: 2
Joined: Mon Jan 07, 2019 11:09 am

"Today" doesn't have any sort of pattern since it's not derived from text. Formats are only needed to translate from text to a date. Once as a date, it's just a date representing a point in time without any sense of format.
Mr_Noodle
Site Admin
 
Posts: 8363
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

So glad I found this topic! Thanks to the help here I've been able to replicate the workflow of moving today's folder contents into an inbox folder. Thanks!

I have two further questions, if I may:

1) Is it possible to use a partial match for today, i.e. MM-DD instead of YYYY-MM-DD? Then I can generate a year's worth of MM-DD folders and recycle.

If not -- can I use Hazel to generate the next year's folders every, say 1st July? Or maybe a rule that checks to see if the next year's worth of folders are there and generate if not? (Last bit might be illogical / too fiddly!)

Thank you very much in advance!
walafrid
 
Posts: 2
Joined: Mon Sep 02, 2019 10:57 am

For matching, you can use a partial format. Hazel will fill in the parts that are missing with the current date. Note that this is just the date internally. When you use it later, for example, as a folder name, you can format it to only use the parts you are interested in.
Mr_Noodle
Site Admin
 
Posts: 8363
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Hi,

Thank you so much for getting back to me. I'm not sure if I misunderstood what you are saying, but I can't get the rule conditions to match as hoped.

I have a "Tickler" folder set up with folders named "MM-DD". For example, today is 8th September, so the folder for today would be named "09-08".

Here's what I have for a rule acting on the "Tickler" folder

1) Name matches •folderDate [where "•folderDate" is a custom date match pattern in the format MM-DD]
2) •folderDate is Today
3) Kind is Folder

When Previewing against the "09-08" folder, rule 2 doesn't match - the popover shows •folderDate as "8 Sep 1 at 00:00"

By contrast, if I change the folder format to YYYY-MM-DD and change •folder date to match YYYY-MM-DD, in the rule 2 preview the popover shows •folderDate as "8 Sep 2019 at 00:00" and the rule does match.

I'd be grateful for your help! Ultimately I'm looking to save time by creating a year's worth of folders in the MM-DD format, rather than having to generate perpetual folders with the years as well!

Thank you very much in advance,

James
walafrid
 
Posts: 2
Joined: Mon Sep 02, 2019 10:57 am

If the year is provided, you should match that. You are not required to include the year later when you name things.
Mr_Noodle
Site Admin
 
Posts: 8363
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support

cron