Page 1 of 1

Rename file based on conditional contents

PostPosted: Wed Jan 08, 2014 6:53 pm
by odornd
To make things easier I'll give my example and go from there.

Say I have a bill in PDF form from an insurance company. I want Hazel to look at the contents and see if my bill is an Auto Policy, House policy, Life policy, etc. I know how to search for those things, but what I'm curious about is naming the file based on what Hazel finds. If it is an Auto Policy, I would like that in the name, etc. I guess I could do this in multiple rules, but if I could do it in a single rule that would be great. Possible?

Maybe an apple script would work, but I'm not very familiar with using it.

Re: Rename file based on conditional contents

PostPosted: Thu Jan 09, 2014 4:23 pm
by Mr_Noodle
Is the text "Auto Policy" in the contents? If so, you can store that in a custom token. Otherwise, if you are just looking for some text that you don't want in the name, but distinguishes the document as an auto policy, then you will have to do separate rules or a script at the moment.

Re: Rename file based on conditional contents

PostPosted: Sat Jan 11, 2014 3:19 pm
by odornd
The string "Auto Policy" is in the contents and I do want it in the name. My goal is something like this...

Search the document for contents containing the string, "Auto Policy", or "House Policy", or "Life Policy". Store the one that Hazel finds as a token for use in the name.

Re: Rename file based on conditional contents

PostPosted: Mon Jan 13, 2014 3:54 pm
by Mr_Noodle
You can try using "Contents contain match" and use a custom token to match some text and then the word "policy". You can then use that custom token in a rename action. Search for "match patterns" in the help.