Needed a small utility to use in batch files to find and replace text in a file.
An example:
I'm using it for a tiny templating engine for CSS files
Code: (autohotkey)
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
TheFile = %1%
TheSearch = %2%
TheReplace = %3%
if 0 < 3
{
MsgBox This script requires at least 3 incoming parameters but it only received %0%.
ExitApp
}
FileRead, Contents, %TheFile%
StringReplace, Contents, Contents, %TheSearch%, %TheReplace%, A
FileDelete, %TheFile%
FileAppend, %Contents%, %TheFile%
Contents = An example:
Code
>type test.txt
greg is a lovely guy
>frep test.txt greg john
>type test.txt
john is a lovely guyI'm using it for a tiny templating engine for CSS files







VanDragt.com

Could someone move this to the finished snacks section please?