FILTERFILES
— Pass files
through a text filter command.
Syntax:
FILTERFILES
/B:.
ext /C /J /N /P /Q /S /UTF8 /UTF16
filespec… :
command
args…
/B:. ext | extension for backups; the default is .original |
/C | do not abort if the command exits with errorlevel 3 |
/N | not really |
/N | disable features |
/J | redirect input |
/P | prompt for each file |
/Q | quietly |
/S | search in subdirectories for matching files |
/UTF8 | redirect output as UTF-8 |
/UTF16 | redirect output as UTF-16 |
… | Range options are also supported. |
filespec… | the files to process; at least one filespec is required |
command | a filter command which writes to stdout |
At least one filespec is required. Anything after the first unquoted colon is the command to execute; this also is required.
Matching files will be renamed with a .original
extension, or as per /B
. Then the specified command
will be called, passing the new filename on its command line after any
args, and with its output redirected to the new
filename.
This command only supports local files. CLIP:
, URLs, standard
input, and so on are not supported.
/N
by itself prevents FILTERFILES
from doing anything. Matching files will be displayed but not renamed, and the
command will not be executed.
/N
with suboptions disables features:
/NC | disable highlight |
/ND | do not search into hidden directories; only useful with /S |
/NF | suppress the file-not-found error |
/NJ | do not search into junctions; only useful with /S |
/NZ | do not search into system directories; only useful with /S |
You can combine these, e.g. /NDJ
.
/P
causes FILTERFILES
to
prompt before processing each file. You can press:
Y | to filter the file |
N or Esc | to skip the file |
A | to stop prompting and filter all remaining files |
Q | to exit immediately |
/UTF8
and /UTF16
let you
set the output encoding. They call OPTION //UnicodeOutput=
and OPTION //UTF8Output=
before processing files, and then
restore the original settings before FILTERFILES
exits. Note
that //UTF8Output
does not actually work in TCC/LE.
By default, FILTERFILES
passes each
original filename to the command on its command
line:
filtercmd "file.original" > "file.txt"
If you specify /J
, it will use input redirection instead:
filtercmd < "file.original" > "file.txt"
FILTERFILES
is mainly intended for use with the filters in this
plugin: DEDUP
, DEGAS
,
DEHTML
, WRAP
,
and so on. But you can use it with any command that either accepts a filename
on its command line or reads from standard input, and that writes text to
standard output.
rem Convert all .TXT file in the current directory to Pig Latin:
filterfiles *.txt : oink
rem Add line numbers to MyFile.txt:
filterfiles myfile.txt : type /L