Issues with recognizing dates

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

Moderator: Mr_Noodle

Issues with recognizing dates Sun Jun 19, 2016 7:26 am • by dorian_grey
Hello,

I'm trying to recognize a date inside a file's contents to use it in the renaming of said file.

The recognized content is

Rechnungsdatum
26. April 2016


I want to be able name the file according to the following pattern

YYYY_MM-company-text.extension

I set up the following, using Hazel's built in Custom Date function for each part:

Image

Day:

Image

Month:

Image

Year:

Image

When previewing I get the following (not what I expected):

Image

Questions:
* What did I do wrong?
* What's the difference between an empty and a filled circle in a token?
* Why is the current time added at the end?
dorian_grey
 
Posts: 20
Joined: Sun Sep 04, 2011 8:01 am

Re: Issues with recognizing dates Sun Jun 19, 2016 9:43 am • by hepabolu
Rechnungsdatum
26. April 2016


Hi, just a question: are you sure 'Rechnungsdatum' is exactly in front of your date? I noticed that, when OCR-ing scanned papers (or even when receiving PDFs), the order of the information is not always equal to what you would expect. So the dates you might get are taken from somewhere else in the file. The advice here is to skip the 'Rechnungsdatum' text.

What you could also try is use the 'CustomDate' variable and set the pattern to the entire date. I have more luck with that one than setting a date with individual patterns.

Hope this helps.

Bye, Helma
hepabolu
 
Posts: 16
Joined: Sat Aug 11, 2012 10:47 am

Re: Issues with recognizing dates Sun Jun 19, 2016 9:52 am • by dorian_grey
hepabolu wrote:are you sure 'Rechnungsdatum' is exactly in front of your date?


Yes, I'm sure. The quote in my first post is copy-pasted from Hazel's content preview.
There is a linebreak after "Rechnungsdatum" though, but as I put a SPACE between "Rechnungsdatum" and the date Hazel shouldn't have any problems with that - afaik Hazel truncates multiple spaces and linebreaks within a SPACE.

What you could also try is use the 'CustomDate' variable and set the pattern to the entire date. I have more luck with that one than setting a date with individual patterns.


I already tried this and it works far better (I'm wondering if Hazel's Custom Date token was supposed to be only used like that? @Mr.Noodle), however two problems:

1. I can't reference individual parts of the date in the next step (where I want to rename the file). I can only use the whole "Date" token.
2. The current time is still added inside the "Date" token, although I didn't put it there.

If you can help me solve 1 and 2 using the Custom Date token would be a perfect solution!

Thanks for your help!
dorian_grey
 
Posts: 20
Joined: Sun Sep 04, 2011 8:01 am

Re: Issues with recognizing dates Sun Jun 19, 2016 10:13 am • by hepabolu
1. I can't reference individual parts of the date in the next step (where I want to rename the file). I can only use the whole "Date" token.


In the part where you put in the variable from the Custom Date you can again change the pattern, so you can take out the day and move the order of the other parts around. Just click on the little down 'v' to the right of the variable name. Now you get a little popup menu where you can change the pattern and even do some math (e.g. substract 1 from the month to indicate it's the bill for the previous month).

2. The current time is still added inside the "Date" token, although I didn't put it there.


This is just a hunch, but could it be that you've set up the time in your System Preferences as part of your dates? Not sure if this is at all relevant, but it might be worth to check it.

Or, open the file and copy and paste the part you want it to match to a text editor (i.e. without any formatting). That might reveal what Hazel sees.

Update: do you see the time in the actual renamed filename? I noticed in the preview window that I too get date AND time, when I'm sure there is only a date. But the renaming doesn't use the time part.

Hope this helps.

Bye, Helma
hepabolu
 
Posts: 16
Joined: Sat Aug 11, 2012 10:47 am

Re: Issues with recognizing dates Sun Jun 19, 2016 11:46 am • by dorian_grey
In the part where you put in the variable from the Custom Date you can again change the pattern, so you can take out the day and move the order of the other parts around. Just click on the little down 'v' to the right of the variable name.


Ha, thank you so much! I didn't know I could edit the "Date" token's output. :D

So my problem is solved ... though I'd still be interested in the answers to my three question from the first post @Mr.Noodle.
dorian_grey
 
Posts: 20
Joined: Sun Sep 04, 2011 8:01 am

Re: Issues with recognizing dates Mon Jun 20, 2016 11:26 am • by Mr_Noodle
In the preview window, you'll notice the ... button. Click that to expand to show you all the text. As noted by hepabolu, the contents may not be what you expect.

Empty circle is a date token. Filled is a text one.

Keep in mind that any "date" is actually a date and time. Any missing parts of the date are filled in with the current one. So if there was no time read in, then it will use the current time. Likewise if you omit the day part, for instance.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support