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

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

Moderator: Mr_Noodle

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
cengel
 
Posts: 6
Joined: Fri Jun 28, 2019 9:53 am

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.
Mr_Noodle
Site Admin
 
Posts: 11868
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support