Replace Text Multiple Files in Batch
A sample batch file to run SED (search the Scribble Web for links to a Dos version) on many files and save the output to a new folder. Note that this basic batch command set is useful for running any single command against every file in a folder.
This code apparently requires Windows NT/2K/XP.
FWIW, this sample makes a new copy of a bunch of .html files into a new folder and replaces all occurrences of the "ZH-CH" font encoding declaration with an English substitute (which works, because it's all miscellaneous formatting like spaces and commas, not words and characters!)
REM @echo off
REM from http://www.experts-exchange.com/Operating_Systems/MSDOS/Q_20737160.html
REM set scriptfile={Put the name of your perl script here right after the "=" and with no braces}
REM set movepath={Put the directory path you want to move the files to here after the "=" and with no braces!}
set movepath=e:\esi2\htm\new
for %%f in (*.html) do (
REM %scriptfile% %%f
sed -e s/ZH-CN/EN-US/g %%f > %movepath%\%%f
REM move %%f %movepath%
)
REM for %%v in (scriptfile movepath) set %%v=
tags: sed, bulk, edit, files, all, loop, batch
>>
Leonard Chan's Homepage
>>
Scribble Web
>> Replace Text Multiple Files in Batch