change file creation date to custom date from file content

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

Moderator: Mr_Noodle

Hello,

can anybody help with this:

I want to setup a rule to change the creation date to a custom date (variable from "contain match" condition)

I guess this should be possible by running embedded script with "touch -t". But unfortunately I have no clue how to use the variable hazel extracts from the file content within this script.

Thank you in advance for any help.
Michael
mikeby
 
Posts: 4
Joined: Thu Jun 09, 2016 10:58 am

You would need to use an AppleScript if you need to pass attributes into the script. The AppleScript can call a shellscript if need be but the important part is that you do the AppleScript in the first place.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Thank you, this helped a big step further. ;-)
mikeby
 
Posts: 4
Joined: Thu Jun 09, 2016 10:58 am

mikeby wrote:Thank you, this helped a big step further. ;-)

Hi all,

I am trying to derive the date from content in a PDF and get it into a token. The real challenge I have is that the format in this invoice is not clearly separated but written out in dutch (ie. 20 Maart 2016). I'd like to rename the PDF to something starting with 20160320_filename.

This might be a way forward for me as well. Did you get any further with an Apple script passing attributes into the Hazel script? I would be interested to see how that works for you in more detail. Thanks for sharing!

Cheers, Deeks
deeks
 
Posts: 9
Joined: Sun May 29, 2016 5:58 pm

I don't think you need any script for this. Create a custom date token and have it match your date. Make sure to set the format to match the textual version of the month and you should be set.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Thanks for jumping in, no luck so far. Does Hazel recognise dutch months?
regards, Deeks
deeks
 
Posts: 9
Joined: Sun May 29, 2016 5:58 pm

this is what i have done so far
http://www.dutchkiwis.com/share/Screen%20Shot%202016-06-15%20at%2021.55.11.png

http://www.dutchkiwis.com/share/Screen%20Shot%202016-06-15%20at%2021.54.53.png
Note that in the second screenshot there needs to be a token in order to see the output. Its just not in the screenshot yet.

And the pdf here
http://www.dutchkiwis.com/share/factuur_TEST_ENvsNL.pdf

Am i overseeing something?

Cheers, Deeks
Last edited by deeks on Wed Jun 15, 2016 6:18 pm, edited 1 time in total.
deeks
 
Posts: 9
Joined: Sun May 29, 2016 5:58 pm

Turns out i needed spaces between the date tokens to match the date pattern properly :o

But....there seems to be a language thingy. As per PDF in previous post, there are three dates in the PDF. With a match on the first occurrance it works sweet.

Invoicedate 22 April 2011
NL date 29 Maart 2010
EN date 13 March 2012

Set the trigger of the token to display the second date and Hazel finds....the third line.
Is there a way to get Hazel to distinguish towards region specific long date formats (foreign formats?)

Cheers, Deeks
deeks
 
Posts: 9
Joined: Sun May 29, 2016 5:58 pm

In your language preferences, Hazel will use all the languages in the list in order. So try making sure Dutch comes before English there.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr Noodle is spot on again :D

Dutch was not in my language settings at all (seems funny for a Dutchie but I have a German laptop). Adding dutch fixed it.

Works like a charm, thanks again!
deeks
 
Posts: 9
Joined: Sun May 29, 2016 5:58 pm


Return to Support