Page 1 of 1

change file creation date to custom date from file content

PostPosted: Thu Jun 09, 2016 11:06 am
by mikeby
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

Re: change file creation date to custom date from file conte

PostPosted: Thu Jun 09, 2016 11:56 am
by Mr_Noodle
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.

Re: change file creation date to custom date from file conte

PostPosted: Fri Jun 10, 2016 4:04 am
by mikeby
Thank you, this helped a big step further. ;-)

Re: change file creation date to custom date from file conte

PostPosted: Wed Jun 15, 2016 7:16 am
by deeks
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

Re: change file creation date to custom date from file conte

PostPosted: Wed Jun 15, 2016 12:15 pm
by Mr_Noodle
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.

Re: change file creation date to custom date from file conte

PostPosted: Wed Jun 15, 2016 3:51 pm
by deeks
Thanks for jumping in, no luck so far. Does Hazel recognise dutch months?
regards, Deeks

Re: change file creation date to custom date from file conte

PostPosted: Wed Jun 15, 2016 4:59 pm
by deeks
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

Re: change file creation date to custom date from file conte

PostPosted: Wed Jun 15, 2016 5:17 pm
by deeks
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

Re: change file creation date to custom date from file conte

PostPosted: Wed Jun 15, 2016 6:56 pm
by Mr_Noodle
In your language preferences, Hazel will use all the languages in the list in order. So try making sure Dutch comes before English there.

Re: change file creation date to custom date from file conte

PostPosted: Fri Jun 17, 2016 4:01 pm
by deeks
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!