Using flexible date patterns

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

Moderator: Mr_Noodle

Using flexible date patterns Sat May 04, 2019 3:44 pm • by graeme
So I have a bunch of files I'm scanning. Most are for the current year, but some are from the past. What I'd like to do is sort files into folders by year. For example, I have a folder called "Tax", and the following within:

* 2016
* 2017
* 2018
* 2019

And in 2020 there will be a 2020 folder as well. Is there a way to make rules such that if all of the conditions are met:

* contains tax
* contains/matches "CurrentYear"

Then the item will be moved into /tax/CurrentYear/

I looked at the manual, and I couldn't find anything simple for setting the current year. Maybe it can be done with AppleScript. Would be really useful to be able to do this, as it would prevent me having to chance the rules in future years too.

The way I'm doing it is:

1. Scanning the files en masse
2. Looking at them and Giving them a name like "Government return Tax CurrentYear"

The latter two words handle the sorting. But right now I just manually entered 2019, so this only works for documents from this year. I'd like a rule just detects any year, and puts the item in the appropriate subfolder.
graeme
 
Posts: 2
Joined: Sat May 04, 2019 3:38 pm

Re: Using flexible date patterns Mon May 06, 2019 10:52 am • by Mr_Noodle
You'll need to determine where Hazel should get the date from. Since you are scanning old documents, you'll probably have to get it from the contents of the file itself. Once you have that date, you can use it in the "Sort into subfolders" action.

Search the help for "match patterns" as that will be necessary to do this in a concise manner.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Using flexible date patterns Fri May 10, 2019 3:42 pm • by graeme
Mr_Noodle wrote:You'll need to determine where Hazel should get the date from. Since you are scanning old documents, you'll probably have to get it from the contents of the file itself. Once you have that date, you can use it in the "Sort into subfolders" action.

Search the help for "match patterns" as that will be necessary to do this in a concise manner.


Oh thanks! I was actually planning to just manually name the files. I'm giving each a descriptive filename, and then two things for Hazel: the date and the category. So I might name something:

Super unique filename tax 2016

And then this hopefully would get put into the folder:

/scans/tax/2016

So, I guess I'm looking for it to do something like:

1. If there is a year
2. Then put in in folder /scans/tax/year

And there will always be a year. I just want hazel to be able to sort it, rather than putting it all in /scans/tax/ and manually dragging. But it wasn't clear to me whether I can detect and use the year as input from the filename in that way.

So, I think I figured out the match patterns bit. I picked a custom date, named it year, edited attribute, and select the "1999" format. I'm guessing this means if I write 2017, it will take that to be the "year".

I'm not sure about folder sort. I found the "sort into subfolder" option, but that doesn't sound right. I tried it with the following path to the folder with /year at the end (the custom date variable), and nothing happened.

I would have used move, but "move" doesn't seem to allow the specification of a path, only a GUI selector. Unless I missed the path option.

Have I made a mistake on the custom date section, or the move section?

Thanks!
graeme
 
Posts: 2
Joined: Sat May 04, 2019 3:38 pm

Re: Using flexible date patterns Mon May 13, 2019 11:18 am • by Mr_Noodle
Can you post a screenshot of your rule? For images, you'll need to use a third party image sharing service, like imgur.com.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support