- @echo off&setlocal enabledelayedexpansion
- for /r "C:\abc" %%a in (*.txt) do for /f "tokens=1* delims=:" %%c in ('findstr /bi "名称:" "%%a"') do (
- set "d=%%d"&set "d=!d:/=_!"
- for %%b in ("%%~dpa*") do ren "%%~b" "!d!%%~xb"
- ren "%%~dpa" "!d!"
- )
复制代码 或:- @echo off
- for /r "C:\abc" %%a in (*.txt) do for /f "tokens=1* delims=:" %%c in ('findstr /bi "名称:" "%%a"') do (
- set "d=%%d"
- setlocal enabledelayedexpansion
- set "d=!d:/=_!"
- for %%b in ("%%~dpa*") do ren "%%~b" "!d!%%~xb"
- ren "%%~dpa" "!d!"
- endlocal
- )
复制代码
[ 本帖最后由 hanyeguxing 于 2011-1-23 23:57 编辑 ] |