@echo off setlocal enabledelayedexpansion for /f "delims=" %%a in ('dir /a-d/b *.txt') do ( set "var=%%~na" echo !var!%%~xa set newn=!var:要替换的内容=被替换的内容! echo 替换后的值: !newn!%%~xa ren "%%a" "!newn!%%~xa" ) echo end... paus