Using the Recurse option, it is also possible to search subdirectories recursively for any given filename or wildcard specification and replace multiple words or phrases in multiple files. The Verbose option allows a visual report of every file accessed as well as how many "hits" the program finds in terms of it's search and replace mission in each particular file. A final tally of search and replace "hits" is always produced by default at the end of each program run.
Logging is available on each run. The logfile is written in the home directory of the Replace Text (rt) executable and is named Rt.Log. Rt.Log is rewritten with each running of Replace Text (rt) that requests Logging as an option. By selecting the O option, logfiles will contain Only the names of files that contained the SearchTerm and have been changed.
Complex changes may be written to File and read by the program. Reasons to use this method may be:
rt FileName, SearchTerm, ReplaceTerm, Option
FileName | string | Name of file to operate on. May be filename only if in the current directory, a fully qualified filename if located elsewhere or a filename spec with wildcards. (example: *.txt or c:\apps\*.txt) | N/A | N/A | Y |
SearchTerm | string | Text to search for and replace with ReplaceTerm. Complex SearchTerm's may be read from file. (See /F parameter) | N/A | N/A | Y |
ReplaceTerm | string | Text that will replace SearchTerm. Complex ReplaceTerm's may be read from file. (See /F parameter) | N/A | N/A | Y |
Option | string | Options may be listed in any order. C - Indicates a Case-sensitive search. Defaults to non case-sensitive searches when this Option parameter remains unused. F - Retrieve SearchTerm and ReplaceTerm from a created File. The file must reside in the rt.exe directory and must be named rt.dat (See Notes for more) L - Logging. Logs all files accessed and the numbers of "hits" and replacements made in relation to each file. O - Log Changes Only. Logs files that contain "hits" and replacements only. The Logging option is implied by selecting this option and does not have to be set separately. R - Recurse subdirectories. Searches subdirectories and operates on all files of the same name or wildcard specification. V - Verbose. Each file that is accessed is listed and reported on. (Number of occurances and replacements) By default, only the total number of files, occurrances and replacements are reported.
|
N/A | Non-sensitive Non-logging Non-verbose Non-recursive Non-file based |
N |
No errors | |
File not found | |
Parameter incorrect | |
Unable to read file or file data has no value | |
Could not write to file, may be read-only | |
RexxUtil could not be loaded | |
Operation canceled by user |
Read C:\MyFile.txt, locate instances of Old Text in any case
and replace it with New Text. (Upper or Lower)
rt C:\MyFile.txt, Old Text, New Text
Read C:\MyFile.txt, locate instances of Old Text
case-sensitively and replace it with New Text.
rt C:\MyFile.txt, Old Text, New Text, /C
Read all *.txt files in the C:\Apps directory, locate instances
of Old Text (any case) and replace it with New Text. Report number
of hits and replacements in each file "on screen" and in a logfile. (rt.Log)
rt C:\Apps\*.txt, Old Text, New Text, /VL
Read all ReadMe.txt files in the C:\Apps directory and all of it's
subdirectories, locate instances of Old Text (Case-sensitively) and replace
it with New Text. Report number of hits and replacements in each file.
rt C:\Apps\ReadMe.txt, Old Text, New Text, /CVR
Read all ReadMe.txt files in the C:\Apps directory and all of it's
subdirectories, use Old Text and New Text that is read from the
rt.dat file. Log changes only.
rt C:\Apps\ReadMe.txt,,, /FOR
Display syntax help.
rt ?
Example 1:
SearchTerm This is text to replace, it can be almost anything. ReplaceTerm This is the new text I want to use. rt.dat contents: Notice ReplaceTerm always starts on the line following the ~END~ delimiter from SearchTerm
|
Example 2:
SearchTerm This is text to replace It's on two different lines ReplaceTerm This is the new text I want to use. It will be spread over five separate lines that include an empty line at the end. rt.dat contents: Notice how adding empty lines in ReplaceTerm before the ~END~ delimiter adds empty lines to the output.
|
Example 3: Like above but extraneous data is added after the second ~END~ delimiter without
affecting operation.
SearchTerm This is text to replace It's on two different lines ReplaceTerm This is the new text I want to use. It will be spread over five separate lines that include an empty line at the end. rt.dat contents: Notice that nothing after the second ~END~ has any effect on the search and replace operations.
|
Remember that line breaks will be found or replaced just as they are specified in the rt.dat file.