Renaming historical docs based on contents

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

Moderator: Mr_Noodle

As I move to the paperless world, I am going thru a backlog of PDFs which I'm downloading from various places. My biggest question is renaming the file based on the date content within the OCRed PDF.

I would love to use the syntax:

year-month - nameofcompany.pdf

An example is from E-ZPass.

I download a PDF from them called, 'statementView.do.pdf' which goes into Downloads (all their statements have this name)

My current HAZEL rule says:

1. Kind is PDF
2. Name is statementView.do.pdf
3. Contact contains "Account Number: XXXXXXXX"

These work fine, but it doesn't address how to rename the files.

Ideally one of two things would happen.

1. Look at the content of the file for the Statement date (OCR TXT is Statement Date: 06/03/12)
2. Since the statement date is different from the activity, I would want to subtract 1 from the month (06/03/12 becomes 05/03/12)
3. For the renaming of the file I would just use the year/month. 12 become 2012 and 05 appended
4. new file name would be 2012-05 - ezpass bill.pdf

I see issues with the math for subtract months (i.e. on a January statement) so I could use the 'Activity For:' text (OCR TXT is Activity For: 05/01/12-05/31/12)

1. I would just want the first part of the dates (i.e. 05/01/12)
2. For the renaming of the file I would just use the year/month. 12 become 2012 and 05 appended
3. new file name would be 2012-05 - ezpass bill.pdf

Any help for a Hazel newbie. In a UNIX environment I would do a

Code: Select all
grep "Activity For:" <filename> | awk '{print$3}' | sed -e s^\/.*\/^/^


Which would pass back 05/12 but I do see that Hazel does anything with variable which could be passed to the renaming function.
desmondfuller
 
Posts: 1
Joined: Wed Aug 22, 2012 10:16 am

You need to use AppleScript to export those values back to Hazel. Search the help for AppleScript for more details. Also see a_freyer's links here: viewtopic.php?f=4&t=1673
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Did you ever get this to work? I am looking for the same kind of rule. I can't find anything that solves it for me.
Micah643
 
Posts: 3
Joined: Mon Dec 03, 2012 12:09 am


Return to Support