没有必要用 call,一定要用call的话,参数应该是%1而不是%a,像这样:- @echo off
- for /f "delims=" %%a in ('dir /a-d/b "*(001).txt"') do (
- call :Next "%%a"
- )
- pause&goto :eof
-
- :Next
- set "pp=%~1"
- set "pp1=%pp:~,-9%.txt"
- ren "%pp%" "%pp1%"
复制代码 不用call,就像这样:- @echo off
- for /f "delims=" %%a in ('dir /a-d/b "*(001).txt"') do (
- set "Name=%%a"
- setlocal enabledelayedexpansion
- ren "!Name!" "!Name:~,-9!.txt"
- endlocal
- )
- pause
复制代码
|