Page 1 of 1

Question: select one out of multiple date formats

PostPosted: Fri Mar 21, 2014 6:40 pm
by gammachar
Hazel is a wonderful app which made my life a lot easier and 'complicated'.
I am struggling with something that I would have not had to, if I did not know Hazel. :roll:

With recent purchase of a nice scanner and its built-in OCR function, (oh, I love this ScanSnap, too), I tried to scan all my receipts. Since having found out that Hazel can pick up the matched contents from the scanned file, I wanted to put purchase date into the file name automatically.

The problem is that merchants/ vendors use various formats of date, for example, 01-03-2014, 1.3.2014, 01.03.14, 1/03/2014, 01/03/14, 2014-03-01, 03-01-2014, Mar.01.2014 etc.
Like most people, I'd like to put one and consistent format of date for naming my files.
ex. receiptx_yummyrestaurant_paris_2014-0301-1845.pdf

My question is how I can make a rule so that Hazel could put the specific date format into my scanned file.

I'd appreciate if anyone can help me.

Re: Question: select one out of multiple date formats

PostPosted: Mon Mar 24, 2014 2:09 pm
by Mr_Noodle
When you add the date token to your pattern for renaming, click on it and you'll see an option to edit the date format. There you can format the date however you want.

Re: Question: select one out of multiple date formats

PostPosted: Mon Mar 24, 2014 4:19 pm
by gammachar
Hi Mr. Noodle, Thank you for your answer.

I should have made my question clearer.
My question was how I could pick up the various date formats by one rule.

Since I do not have any idea how to make it simple, I made a long list of 'contents match' nested rules each of which has a specific format. I know it is not a good solution, but at least it works for me. Although not being really satisfied with it, I learned a lot how to use Hazel while having struggled with any possible solutions. :) I appreciate again for making this great app.

(Btw, on my 13" 2010 MacBook, I cannot put more than 10 lists, because I cannot edit the custom token which lies below the screen. It is not a Hazel issue, but a system preference one, because its screen cannot be resized.)

Re: Question: select one out of multiple date formats

PostPosted: Wed Mar 26, 2014 12:17 pm
by Mr_Noodle
I am looking into adding the capability of having several patterns for a single custom token but yes, for now you'll have to have a separate condition for each one with a new custom token in each case.

Re: Question: select one out of multiple date formats

PostPosted: Fri Feb 06, 2015 7:48 am
by Andre
Hi Gammachar,
would you mind sharing your nested rule for multiple dates?
I'm having exactly the same challenge.

Thanks and regards,
Andre

gammachar wrote:Hazel is a wonderful app which made my life a lot easier and 'complicated'.
I am struggling with something that I would have not had to, if I did not know Hazel. :roll:

With recent purchase of a nice scanner and its built-in OCR function, (oh, I love this ScanSnap, too), I tried to scan all my receipts. Since having found out that Hazel can pick up the matched contents from the scanned file, I wanted to put purchase date into the file name automatically.

The problem is that merchants/ vendors use various formats of date, for example, 01-03-2014, 1.3.2014, 01.03.14, 1/03/2014, 01/03/14, 2014-03-01, 03-01-2014, Mar.01.2014 etc.
Like most people, I'd like to put one and consistent format of date for naming my files.
ex. receiptx_yummyrestaurant_paris_2014-0301-1845.pdf

My question is how I can make a rule so that Hazel could put the specific date format into my scanned file.

I'd appreciate if anyone can help me.

Re: Question: select one out of multiple date formats

PostPosted: Fri Feb 06, 2015 4:57 pm
by Mr_Noodle
Note that in the latest version of Hazel, you can use re-use custom attributes. Therefore, you can have multiple conditions all use the same custom attribute, using a different date format for each one. Only the first one which matches will get assigned to the attribute itself.

Re: Question: select one out of multiple date formats

PostPosted: Thu Feb 12, 2015 2:13 am
by JBB
Another challenge with solving this problem is the document may have several different dates. A useful enhancement would be to have more options than just "nth from beginning/end", e.g., earliest, latest, closest to today. Another enhancement I thought of would be for Hazel to be more tolerant with OCR errors, e.g. "ll' (two lower case L's) could match as 11 (number eleven).

Re: Question: select one out of multiple date formats

PostPosted: Thu Feb 12, 2015 12:31 pm
by Mr_Noodle
I'll consider the date thing though concrete examples will help here.

Yeah, it's a bit tough with OCR errors. There are a ton of ways for things to go wrong and not all of them are easily detectable and could make pattern matching much slower, depending. Nonetheless, it's something I'm considering.

Re: Question: select one out of multiple date formats

PostPosted: Fri Jan 13, 2017 5:46 pm
by dissolved
Mr_Noodle wrote:I'll consider the date thing though concrete examples will help here.

Yeah, it's a bit tough with OCR errors. There are a ton of ways for things to go wrong and not all of them are easily detectable and could make pattern matching much slower, depending. Nonetheless, it's something I'm considering.


I too would like a way to say "earliest" or "latest" date matched. A concrete example is my water bill for some reason matches the billing date as the 1st occurrence and sometimes the 2nd occurrence, but regardless the earliest date is always the bill date (with the latest date being the due date). I'm sure a work around is to add some script, but would love a built in solution to this problem.

Re: Question: select one out of multiple date formats

PostPosted: Mon Jan 16, 2017 3:07 pm
by Mr_Noodle
Is there some text surrounding the date that you could use to match?