Page 1 of 1

Replace text in .txt file

PostPosted: Fri Sep 18, 2020 10:21 am
by antidote
Hello,
this is my first time posting here. I am new to hazel and scripting but I start to see the great opportunities using hazel and coding.
In a folder i get a text file which contains among other things the following line
12000 = value1 (e.g. 10.3) -->V1
I have managed to contain match and gave the parameter name V1 using hazel. Now I need to add the following rule:
if V1 <= 50 then add to value 40,
example if the txt file contains the line: 12000 = 60.3 then do nothing
if the txt file contains 12000 = 40.1 then replace text so the final txt file contains the line 12000 = 80.1 (40.1+40).
I understand that I must apply some kind of scripting but my knowledge is extremely limited.

Re: Replace text in .txt file

PostPosted: Fri Sep 18, 2020 2:59 pm
by Mr_Noodle
Hazel does not have any built-in actions to modify the contents of files. You will definitely need to use a script of some sort. AppleScript is a bit more approachable but with a shell script, there may be more tools that can directly help you.