John Fitzsimons said:
Hi, suppose I have eg. 500+ .html files that I want to do a "search
and replace" in. What programs, if any, would be able to handle
such a task ?
Regards, John.
Hi John,
Visit
http://users.erols.com/waynesof/bruce.htm and try CHANGE.
Here's a list of the options;
CHANGE pgm by Bruce Guthrie, (c)2002 U.S. Dept of Commerce Revised
08/10/2002
Missing required parameter(s). Requires at least input file name.
CHANGE written by Bruce Guthrie, U.S. Dept of Commerce. Command
syntax:
CHANGE { filespec | (filelist) | @listfile } [ /ATTR=attribs ] [ /S
]
[ /-PROMPT ] [ /Cctlfile | /FROM string /TO string [ /IN search ]
]
[ /LINES { line1-line2 | line1 linect } ... ] [ /V ] [ /I ]
[ /Noutfile [ /OVERWRITE | /-OVERWRITE | /OVERASK ] ]
[ /Frptfile ] [ /Ttempfile ] [ /TRIM ] [ /ZAPNULL ]
[ /TEXT | /BINARY ] [ /VERIFY ] [ /Q | /Qn ] [ /W | /W0 | /-W ]
[ /Iinitfile | /INULL ] [ /-ENV ] [ /? ] [ /?HEX ]
where:
filespec is the specification for the files to be processed; unless
/Noutfile
is provided, this input file are overwritten by the results of the
CHANGE
command; if /Noutfile is not provided, the filespec can include
wildcards
(filelist) allows multiple filespecs separated by spaces
@listfile provides file name that contains a list of files to be
processed
/ATTR=attribs allows you to include/exclude files by attrib; use any
combination of R (read-only), H (hidden), S (system), A (archive
bit);
precede with "-" to exclude instead of include; init def is
/ATTR=-H-S-R
/S recurses through subdirectories; init def is /-S
/-PROMPT says to skip confirmation prompt if /S specified; init def
/PROMPT
/Cctlfile is the name of a file that contains the various changes to
be
made. Lines must have -F, -T, -I, -C specifications for
from/to/in/cols
If a ctlfile is not provided and you do not provide any TO/FROM
parameters, you will be prompted for changes to make
/FROM string /TO string [ /IN search ] allows you to specify what to
change
from and to in (optionally) whatever at the command line instead
of
being prompted or needing a ctlfile. The /IN search option allows
the
Boolean search options shown below; they are not available if
prompted
for the /IN string or when reading from an input file; /FROM
string can
end with "*" in which case all trailing characters are also
replaced
/LINES specifies lines to process. Multiple specifications can
be used. Defaults to /LINES 1-9999999
line1-line2 says to take from line line1 through line2 (also
line1/line2)
line1 linect says to take from line line1 and take the next linect-1
lines
/V says to find those items that do NOT match the specification; def
is /-V
/I says to make it a case-insensitive /FROM and /IN search; note
that the
string you enter for /TO is not affected by this option; init def
is /-I.
/Noutfile is the name of the changed file to create. By default,
the new
file will be the same as the old file, being overwritten if CHANGE
works
/OVERWRITE says to overwrite the output file if it already exists.
/-OVERWRITE says to abort if the output file exists already
/OVERASK says to prompt if the output file exists already; the
default
/Frptfile is the name of the file to write all changes made to.
This only
works in TEXT mode but it contains the original lines that were
changed
/Ttempfile specifies what the name of the intermediate file is to
be.
If the original file is to be overwritten (no /Noutfile is
provided),
a temporary file is created with the revised file and this file is
copied
over the original. Unless otherwise specified, this temporary
file is
written to the same drive as your original file. If that drive
may not
have room for two copies of the same file, you need a /Ttempfile
spec.
/TRIM invokes TEXT mode and removes any blanks from all lines; def
is /-TRIM
/ZAPNULL in TEXT mode deletes any line that gets changed into a null
line;
initial default is /-ZAPNULL
/BINARY reads the file in blocks of 12000 characters. Defaults to
/BINARY
unless /TEXT-required conditions (see next) are met.
/TEXT puts you in TEXT mode, meaning the file will be read one
record at a
time instead of being read in blocks of binary data. TEXT mode is
required
if /IN, /LINES, /Frptfile, /TRIM, or /VERIFY is specified. TEXT
mode
writes all lines out with CR/LF EOL characters.
/VERIFY invokes TEXT mode and asks you to verify each change; def is
/-VERIFY
/Q stops the display of record-by-record status messages
/Qn (def /Q25) shows record-by-record status messages every
n-records
/W waits for a keypress afterward only if any hits are made
/W0 waits for a keypress afterward no matter what; init default in
Win31/95
/-W skips waiting for a keypress afterward; init default in DOS in
WinNT
/Iinitfile says to load an initfile for default values and such;
searches throughout your path for it; defaults to /ICHANGE.INI;
use /INULL to skip entirely
/-ENV says to not resolve possible environmental variables; def is
/ENV
/? or /HELP or HELP gives you this syntactical help
/?HEX gives you help with hexadecimal and decimal codes
for search, the syntax is:
[ ( ]... search_item [ boolean [ ( ]... search_item [ ) ]...] [ )
]...
where:
( and ) are used to group items
search_item is shown below
boolean is AND, OR, or XOR (NOT is included with search_item)
for search_item, the syntax is:
[ NOT ] "string" [ column | col1/col2 ]
where:
NOT is obvious
string the string to search; the quotation marks are typically not
required unless the string contains a space or a reserved
word;
can include hexadecimal codes (see below)
column is the column in which the string must start.
col1/col2 says the string must begin between col1 and col2.
Examples:
CHANGE TEST.TXT /FROM Apple /TO Banana /IN "Bugs Bunny" 12
CHANGE TEST.TXT /FROM Noise /TO Rock /I /IN (Elmer OR Daffy) AND
"Marvin Martian"