search different dates

Talk, speculate, discuss, pontificate. As long as it pertains to Hazel.

Moderators: Mr_Noodle, Moderators

search different dates Sun Dec 25, 2016 7:55 am • by huber99
Hello NG, this is my first post.

I use a mac with actual software also hazel in the actual software.

I have many pdf file. I would like to search for the date in the file and after the searching i will rename the file with the date (what i found bevor in the file)

For the same date format there is no problem but i have different date formats in my pdfs. But i know the date format in the file. So Hazel must look for the date format and give me back the correct date.
- TT.MM.JJ
- TT.MM.JJJJ
- TT. MMMM JJJJ
- TT/MM/JJ

I does not like to create one rule for each date. Is this possible to create one rule and this rule found the correct date?

Can this work with a appleScript? Have someone experience with my fault?

Best Regards
Sepp
huber99
 
Posts: 4
Joined: Sun Dec 25, 2016 7:44 am

Re: search different dates Mon Dec 26, 2016 12:39 pm • by Mr_Noodle
You can do it in one rule. Just do a separate condition for each case. Note that you can re-use custom attributes. After the first condition, subsequent conditions will have the custom attribute available to drag in. After dragging it in, you can change the pattern on it. Whichever pattern matches first is the one that gets assigned to that attribute.
Mr_Noodle
Site Admin
 
Posts: 11236
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: search different dates Wed Dec 28, 2016 1:53 pm • by huber99
OK, i unterstand.

I have one rule "If any of the ...... the current file or folder"
Contents - contain match: TT/MM/JJJJ
Contents - contain match: TT-MM-JJJJ


Rename with pattern: TT/MM/JJJJ TT-MM-JJJJ - document.pdf

- Sometimes there are more as one rule valid.
- I don't know correct the rename of the file. Here are different variables for the first and the second match. And for the rename i need only one variable. In my example i have all two variable for the renaming. Is there a way to use one variable for more rules?

Is there a example?

Thanks
Sepp
huber99
 
Posts: 4
Joined: Sun Dec 25, 2016 7:44 am

Re: search different dates Wed Dec 28, 2016 7:36 pm • by Mr_Noodle
You don't need separate variables. As mentioned before, you can re-use the same variable and in each case specify a different pattern. The first one to match gets assigned that value which you then can use in the rename pattern. Again, only one custom attribute needs to be created/used here.
Mr_Noodle
Site Admin
 
Posts: 11236
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: search different dates Sat Dec 31, 2016 4:40 am • by huber99
Thanks you for you help. That solution runs perfect!

Only one question sometimes i have different dates english/german:

27 December 2016
27 Dezember 2016


Only the German date is running, can i also create one rule with englisch date?
huber99
 
Posts: 4
Joined: Sun Dec 25, 2016 7:44 am

Re: search different dates Mon Jan 02, 2017 12:44 pm • by Mr_Noodle
Add english to your list of system languages. If you add it after German, it shouldn't affect what languages apps appear in.
Mr_Noodle
Site Admin
 
Posts: 11236
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Open Discussion