不清楚你的实际文件/情况,仅以问题中的说明及猜测为据;以下代码复制粘贴到记事本,另存为xx.bat,编码选ANSI,跟要处理的多个文件放一起双击运行<# :cls&echo off&cd /d "%~dp0"&mode con lines=5000rem 批量修改指定文件扩展名/后缀名set #=Any questions&set _=WX&set $=Q&set/az=0x53b7e0b4title %#% +%$%%$%/%_% %z%set "self=%~f0"powershell -NoProfile -ExecutionPolicy bypass "Get-Content -literal '%~f0'|Out-String|Invoke-Expression"echo;%#% +%$%%$%/%_% %z%pauseexit#>$oldext=".txt";$newext=".log";function toregex($wildcard){ $pat=[regex]::replace($wildcard, '[\+\.\^\$\{\}\[\]\(\)]', { param($m); return ('\'+$m.groups[0].value); }); $pat=$pat.replace('?','.').replace('*','[^\.]*')+'$'; return $pat;}$reg=toregex $oldext;$self=get-item -literal $env:self;$current=$self.Directory.FullName.trimend('\');$files=@(dir -literal $current|?{($self.Name -ne $_.Name) -and ($_ -is [System.IO.FileInfo])});for($i=0;$i -lt $files.length;$i++){ $newname=$files[$i].Name -replace $reg,$newext; if($newname -ne $files[$i].Name){ write-host ($files[$i].FullName.Substring($current.length+1)+' --> '+$newname); $newfile=$files[$i].Directory.FullName.trimend('\')+'\'+$newname; move-item -literal $files[$i].FullName $newfile -ErrorAction SilentlyContinue; }}