我也来一个- @echo off
- for /f "delims=" %%a in ('dir /a-d/s/b *.rm^|findstr /ie "\.rm"') do (
- set str=%%a
- setlocal EnableDelayedExpansion
- call :check
- for %%i in (!NaN!) do echo ren "!str!" "!str:~-%%i!"
- endlocal
- )
- pause&exit/b
- :check
- for /l %%i in (4 1 260) do (
- if "!str:~-%%i,1!" lss "0" (goto :eof) else if "!str:~-%%i,1!" gtr "9" goto :eof
- set NaN=%%i
- )
复制代码 上面为什么到260,是因为UNC通用命名规则规定:路径(文件的完整路径)的最大长度为260个字符。(显然文件名无法件取到260个字符,但上面的代码写260也不会影响效率)
[ 本帖最后由 zqz0012005 于 2009-3-21 00:27 编辑 ] |