Page 1 of 1

Editing tokens midway through a rule

PostPosted: Sun May 09, 2010 1:54 pm
by Tom
I'm currently trying to set up a system to digitise and sort all my university work for the last 3 years on my computer. I've got to revise for vivas on all my work for the last three years, so now seems a good time to go through all the paper notes in my room.

All my lecture courses have course codes in the format "xyyy", e.g. 3P10, where

x is the course year (1, 2, 3, 4)
yyy is O, I or P (organic, inorganic, physical chemistry) followed by a two digit number (which is the course code)

Hazel sorts these into a folder: Year x > yyy and renames it "xyyy name". So I'd rename the scanned file "3P10 Lecture 1" and Hazel sorts it into Year 3 > P10 and names it "3P10 Lecture 1".

What I'd really like is for Hazel to actually name the file, for example, "3P10 Molecular Electronic Materials Lecture 1" because I can't remember all the course codes. How could I go about doing this? The only way I can think of is to have a bit of script that looks into the xyyy token, checks it against some kind of list (in a text file would be great!), finds that 3P10 corresponds to "Molecular Electronic Materials" and then changes the token "3P10" to "3P10 Molecular Electronic Materials" just before it renames the file.

Is this possible?

Thanks for any help! :)

Edit: I've been thinking about this a bit more and perhaps a simpler approach would be to just run an automator action on the folder that does a find and replace on the filenames in each folder. I could do this once I've finished the course and know that it's unlikely to have any files added. If anyone can think of a way to do what I'm after that's not too complicated, I'm still interested though.

Re: Editing tokens midway through a rule

PostPosted: Tue May 11, 2010 5:01 pm
by Mr_Noodle
If the table of course codes to descriptions is pretty short, you can just use separate rules for each case.

If you want it to look up entries in a text file, then you'd have to do a script of some sort. I'm considering adding that sort of capability built-in but I don't think there will be ever a general way to have Hazel use some sort of file for this.