XFILTER — Process lines of a file using variable expansion.

Syntax:
XFILTER /A:attribs /B /CP:n /F:"format" /H /N /P /S /T filename…

/A:attribsattributes mask; valid flags are -ACEHIORS
/Bdiscard blank lines
/CP:ninterpret non-Unicode input text using code page n
/F:"format"format string: required; see below
/Hdisplay filenames
/Ndisable features
/Ppage output
/Ssearch in subdirectories for matching files
/Ttrim leading and trailing whitespace
Range options are also supported.

The required format string contains TCC variables and functions, which will be expanded for each line in the file. Double all percent signs to prevent variables from being expanded before the command is executed. An asterisk in the format string will be replaced with each line from the file. The current (zero-based) line number is also available in the variable _LINE.

XFILTER can be used as a filter reading from standard input, or it can read from one or more files specified on the command line. The resulting text is written to standard output; it can be piped or redirected. If you want to pipe to XFILTER, 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 file in the shell’s PlugIns directory; or else use temporary files or an in-process pipe.

You may specify more than one filename; wildcards and directory aliases are supported. You can search recursively into subdirectories for matching files with /S. @File lists and internet files are supported. You may also specify CLIP: to process text from the clipboard instead of from a file.

To prevent problems caused by troublesome characters in the input text, certain ‘dangerous’ characters from the file will be temporarily replaced with safe alternatives from Unicode’s Halfwidth and Fullwidth Forms block. They will be restored to ASCII after variable expansion. This shuffle prevents issues when characters with special meanings to TCC are inadvertently present in the input text, but it might be confusing if you want to find or replace any of the remapped characters. The characters which are temporarily replaced are:

CharacterASCIIHexRemapped to
"3422U+FF02
%3725U+FF05
(4028U+FF08
)4129U+FF09
,442CU+FF0C
[915BU+FF3B
]935DU+FF3D
^945EU+FF3E
`9660U+FF40

rem  Dump a file in uppercase:
xfilter /f:"%%@upper[*]" "Engine Summer.txt"

rem  Display the length of each line:
xfilter /f:"Line %%_line has %%@len[*] characters." "Engine Summer.txt"