Rename based on the contents of a file?

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

Moderator: Mr_Noodle

Rename based on the contents of a file? Thu Jan 31, 2013 5:00 pm • by clokey74
Hi,

I am seriously getting into my paperless workflow and picked up Hazel via a tip from someones blog. I can't believe how useful this tool is and what great value for money it is.

One question I have is, I am currently using hazel to look at the contents of OCR'd pdf's to work out which subfolder to move it into (which works fine), what i would like to do is to chain a rule that renamed the file based on the contents of the file it's just processed.

E.g. scanfile1-2013-01-30-21:10.pdf contains account number 12345 and billing date:23rd January 2013, so i want the file to go into a directory called 12345, but would like to rename the file to "client-12345-23rd January 2013.pdf"

Is the only way to do this to execute a script (python, applescript) on the moved file (eg write a regex)

Anyway, hope that makes sense, and thanks for any help

M
clokey74
 
Posts: 2
Joined: Thu Jan 31, 2013 4:49 pm

Re: Rename based on the contents of a file? Fri Feb 01, 2013 12:11 pm • by a_freyer
Yes, the only way to do this is with script. Unfortunately, the 'content' metadata attribute is not plaintext; it is a hash of words within the file output from the mdimporter (i.e. for faster searching, etc.).

Happy to help with scripting though.
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: Rename based on the contents of a file? Sun Feb 03, 2013 7:26 pm • by clokey74
Thanks for the feedback. Makes sense thinking about it. I've put some python together to do what I am after so I'll post back if I run into any issues

M
clokey74
 
Posts: 2
Joined: Thu Jan 31, 2013 4:49 pm


Return to Support