Page 1 of 1

How to alter filename

PostPosted: Thu Jun 03, 2010 7:41 am
by KevinMSadler
Hi all,

I want to file bank/credit card statements automatically. The problem is I always download them the month after they are generated! Hazel detects and moves them to the relevant folder and changes the name to:
Year-Month.pdf ie. 2010-05.pdf

Unfortunately when doing this with Hazel the month is always the date the file is downloaded/created and is always 1 month late and I am having to manually rename. This kind of defeats the purpose.

Is there anyway that I can subtract 1 from the month that hazel inserts? Or if I keep the file with the same complex filename suggested by the bank can I take data from the complex filename and create a simpler one from it (in other words a sort of regex manipulation)?

I hope you can help.

Kev

Re: How to alter filename

PostPosted: Thu Jun 03, 2010 2:38 pm
by Mr_Noodle
If you want to do regex type manipulation, look up "match patterns" and "custom tokens" in the help. If the date is in the filename, then you should be able to extract it.

Re: How to alter filename

PostPosted: Thu Mar 31, 2011 12:01 pm
by theterran
Mr_Noodle wrote:If you want to do regex type manipulation, look up "match patterns" and "custom tokens" in the help. If the date is in the filename, then you should be able to extract it.


Hey Mr_Noodle, thanks for pointing to the match patterns help. I was trying to match the first 4 characters in the filename (which are always "year" for me) and sort into subfolders based on 4-digit year. For some reason I went straight for "Number", which matched the full date string (YYYYMMDD), when what I needed was four "Digit" matches. The example in help straightened me right out.

Also while working this out, I found that the help example adds unnecessary components to the "Sort file into subfolder" action. The example shows the pattern "*year > name". However, in my experience it is not necessary to add "> name" to sort the file into the subfolder; if this is not included, Hazel will simply sort the file into the subfolder unchanged.

So in my rule, the action is "Sort file in to subfolder" with pattern "*year". Works great.

Hazel rocks -- thanks!

Re: How to alter filename

PostPosted: Thu Mar 31, 2011 12:43 pm
by Mr_Noodle
Glad you got it working. Looking at the help again, actually, that example will also file it into another folder based on name. I'll have to revisit that as it may create more confusion. Thanks for the heads up.