本帖最后由 went 于 2020-8-18 19:04 编辑
第9行打开重命名- @echo off
- setlocal enabledelayedexpansion
- for /r %%i in ("*%%*.*") do (
- set "newName=%%~ni"
- set "newName=!newName:%%=%%%%!"
- call :getNewName "!newName!"
- echo %%i
- echo !newName!%%~xi
- REM rename "%%i" "!newName!%%~xi"
- echo ------------------------
- )
- pause&exit
-
- :getNewName
- set "str=%~1"
- set "numStr="
- set "newName="
- :loop
- set /a "1/%str:~0,1%" >nul 2>nul && set "numStr=%numStr%%str:~0,1%" || (
- if "%str:~0,1%"=="0" (
- set "numStr=%numStr%0"
- ) else (
- if "%str:~0,1%"=="." (
- set "numStr=%numStr%."
- ) else (
- if "%str:~0,1%"=="%%" (
- set "newName=%newName%百分之%numStr%"
- set "numStr="
- ) else (
- set "newName=%newName%%numStr%%str:~0,1%"
- set "numStr="
- )
- )
- )
- )
- set "str=%str:~1%"
- if not "%str%"=="" goto :loop
- goto :eof
复制代码
|