Page 1 of 1

Rename Text in a Text File

PostPosted: Wed Jan 27, 2021 5:42 pm
by Radkee
Is it possible for Hazel to look into a plain text file, find a word, rename it (or delete it), and save the file?

I want to write words in my file and depending on what I write, it will execute Hazel actions looking for those contents. After I write the word and Hazel does it magic, I need the word to be renamed or deleted, so it doesn’t execute again.

Re: Rename Text in a Text File

PostPosted: Thu Jan 28, 2021 11:16 am
by Mr_Noodle
Hazel does not have any built-in actions to modify the contents of a file. You'll need to look into a script to do that part.

Re: Rename Text in a Text File

PostPosted: Fri Jan 29, 2021 11:37 am
by Radkee
It's good to know it's still possible! I'll research how to do this. Do you recommend a certain language to accomplish this?

Re: Rename Text in a Text File

PostPosted: Fri Jan 29, 2021 12:13 pm
by Mr_Noodle
Might be doable with a regular shell script using 'sed'. You'd have to google around for examples.