Page 1 of 1

Rename Tip? Rule deleting 2nd use of specific word/phrase

PostPosted: Wed Nov 04, 2020 11:45 am
by cengel
Hi - anyone have a trick for using hazel to automate a rule removing the second use of a specified word/phrase in a filename?

For example, I have a study called STEPS, so I automate the renaming of these files starting with the 8 digit date, underscore, STEPS (e.g., "20201104_STEPS_original file name.docx"). The rest of the file name often contains another mention of the inserted word/phrase (e.g., "20201104_STEPS_original STEPS file name.docx") and I'd like to keep my inserted text while deleting subsequent mentions of the same word from the old name. Hopefully that's clear.

Does anyone have a trick renaming rule they use to do this?

Thanks so much,
~Chuck

Re: Rename Tip? Rule deleting 2nd use of specific word/phras

PostPosted: Wed Nov 04, 2020 3:35 pm
by Mr_Noodle
You'll need to use a match pattern of some sort. You can create a custom attribute to match the first occurrence, and re-use it to match the second occurrence later. I'm not sure how consistent the text in between those is so you'll have to structure the pattern to fit that.