Category: "Working on"

Search and Replace in text files

Working on Send feedback »

One of the things that originally prompted me get the idea for the Build Automator was the need to update a collection of class files and template files to accurately reflect the copyright and version number of each file as well as the release date. These files are part of Clarion toolkit that we call the Icetips Utilities that we released last year and we are working on right now.

This process was tedious even though I could use my editor to do a mass search/replace in files. Sometimes I would simply forget this step which added to support issues when customers reported problems in version X when they actually had version Y - because the source files said, incorrectly, that it was version X.

As I'm working on that same collection of classes that prompted my idea for the Build Automator, I remember that particular process so I decided to add an action to do a search and replace on text files. This action is now fully functional and is extremely fast. I let it do two search and replace operations on a folder with over 40 files in it and it took 0.89 seconds to complete on a moderate machine. It can be used on individual files or by using wildcards.

You can of course use variables in the string to search for and in the replacement string. This makes it easy to put in for example todays date formatted nice and neat by using the Set Variable action and set it to an evaluation expression. Use "Format(Today(),@d18)" as the expression, without the double quotes, to get todays formatted as "August 19, 2008" in standard windows long format.

This new action will be included in our September release and now I can get back to work on my class files:)

-- Arnor Baldvinsson

Contact / Help. ©2017 by Arnor Baldvinsson. blog tool / dedicated servers / authors.
Design & icons by N.Design Studio. Skin by Tender Feelings / SkinFaktory.