REPLACETEXT — Replace strings in text from a file.

Syntax:
REPLACETEXT /A:attribs /C /CP:n /H /N /P /R:from:to /S /W /X:from:to filename…

/A:attribsattributes mask; valid flags are -ACEHIORS
/Creplace character escapes (affects following /R: and /X:)
/CP:ninterpret non-Unicode input text using code page n
/Hdisplay filenames
/Ndisable features
/Ppage output
/R:from:tospecify old and replacement text
/Ssearch in subdirectories for matching files
/Wwhole words only (affects following /R: and /X:)
/X:from:tospecify old and replacement text (do not auto-capitalize)
Range options are also supported.

If standard input (stdin) is redirected, REPLACETEXT will read from stdin before any filenames specified on the command line. If no filenames are specified, then REPLACETEXT will read from stdin whether it is redirected or not. Filenames may include wildcards and directory aliases. You can search into subdirectories for matching files with /S. @File lists and internet files are supported. You may also specify CLIP: to read from the clipboard.

If you want to pipe to REPLACETEXT, remember that pipes open a new shell. To pipe to a plugin command, you must either ensure that the plugin is loaded in the transient shell, e.g. by installing the .DLL in the shell’s .DLL directory; or else use temporary files or an in-process pipe.

Use /R: or /X: to specify the strings to search for (from) and to substitute (to). You must have at least one of these; you may add as many as you like. The text from each matching file will be dumped to stdout, with every occurrence of from replaced with the corresponding to string. If you give a from string without a matching to, then matching strings will simply be omitted from the output. The difference between the two options is that /R: automatically capitalizes the to string to match the from text which it replaces, but /X: does not. The rules for /R: are simple:

/W only affects those /R: and /X: options which follow it on the command line. /W prevents matching text which immediately follows or immediately precedes a letter or digit.

/C only affects those /R: and /X: options which follow it on the command line. /C expands character escapes of the form \nnn (decimal) or \Xxx (hexadecimal) in both the from and to text. Use this option to embed troublesome characters. For example, you could use /C /R:\x22: to strip double-quote marks from a file.

/N disables features:

/NBdo not write a Byte Order Mark
/NCdisable highlight
/NDdo not search into hidden directories; only useful with /S
/NFsuppress the file-not-found error
/NJdo not search into junctions; only useful with /S
/NZdo not search into system directories; only useful with /S

You can combine these, e.g. /NDJ.


replacetext "Engine Summer.txt" /w /r:winter:autumn /r:but:yet