@echo off set a=x.txt set b=y.txt set x=xxx set y=yyy pushd d:\ if exist %a% goto ab set c=%a% set a=%b% set b=%c% if exist %% goto ab echo %b% %a%都不存在 goto :end :ab (for /f tokens=* %%i in ('type %a%') do ( set s=%%i call set s=!s:%x%=%y%! echo !s!))%b% del %a% :end puase