入力ファイル「input.txt」内に存在する文字列「foo」を全て「bar」に置換して、出力ファイル「output.txt」に出力する via"http://knowledge.reontosanta.com/archives/816"
@echo off
rem カレントディレクトリ移動(バッチ実行ディレクトリ)
cd /d %~dp0
rem 入力ファイル
set infilenm=input.txt
rem 出力ファイル
set outfilenm=output.txt
rem 置換前文字列
set beforestr=foo
rem 置換後文字列
set afterstr=bar
rem 出力ファイル作成
type nul >%outfilenm%
rem ファイル編集
setlocal enabledelayedexpansion
for /f "delims=" %%A in (%infilenm%) do (
set line=%%A
echo !line:%beforestr%=%afterstr%!>>%outfilenm%
)
endlocal