Page 1 of 1

multiple date format and renaming files with date

PostPosted: Wed Jun 01, 2016 11:13 am
by eco
Hi all,

I just bought Hazel and just discovered that there is no manual so I'm falling back on the forum and you, the experts.

I am trying to do the following:
Code: Select all
if all
   if any
      contain match = bank account
      contain match = other account
   if any
      contain match = date_short (DD/MM/YY)
      contain match = date_long (DD/MM/YYYY)
Do
   move to folder = test
   rename with pattern = Company Name <date_long><date_short><extension>


The problem I have is due to the date. I want to add the billing date to the file name but this particular company varies its format from long to short just to make Hazel sweat a bit.

I tried to be smart and put both long and short date in the name thinking Hazel would fill a blank if the variable was never filled.. but instead it does this:

Code: Select all
Company Name 2016-0520-05.pdf


It basically takes the long date and crops the year after the second digit.

I have reach the end of my skills before falling onto a shell script.

Can this be done without a script?
Am I doing the rule the right way or is there a better way?

This is my first day at it so please bare with me. ;)

Re: multiple date format and renaming files with date

PostPosted: Thu Jun 02, 2016 10:54 am
by eco
OK, after a bit more reading and reflection, I'll answer my own post...

Make two rules.

I was hoping for a more generic rule but I think it goes against the flow.

Re: multiple date format and renaming files with date

PostPosted: Thu Jun 02, 2016 11:30 am
by Mr_Noodle
Actually, what you want to do is use the same attribute for both dates. So, instead of date_short and date_long, just create one date attribute. In the second condition, instead of dragging a new attribute in, drag in the one you created in the previous condition. You can then change the format there. Then you end up with only one thing to add in the rename pattern.

Re: multiple date format and renaming files with date

PostPosted: Thu Jun 02, 2016 6:08 pm
by eco
Great idea, I'll give it a go right away.
Thanks for your time.