标题: 把c盘下所有的文件改名
[打印本页]
作者: flyingphf
时间: 2008-4-17 09:49
标题: 把c盘下所有的文件改名
把c盘下所有的*bb.txt文件改为*cc.txt怎么说啊
作者: bat-zw
时间: 2008-4-17 11:35
标题: 已做了文件名含空格处理:
@echo off
for /f "delims=" %%i in ('dir /s /b c:\*bb.txt') do call :lp "%%i"
pause&goto :eof
:lp
set str=%~nx1
set str=%str:bb=cc%
ren %1 %str%
goto :eof
或者开启变量延迟:
@echo off
for /f "delims=" %%i in ('dir /s /b c:\*bb.txt') do (
set str=%%~nxi
setlocal enabledelayedexpansion
set str=!str:bb=cc!
ren "%%i" !str!
endlocal
)
pause
Last edited by zw19750516 on 2008-4-17 at 11:48 AM ]
作者: flyingphf
时间: 2008-4-17 11:52
我想问下goto :eof 是什么意思
作者: bat-zw
时间: 2008-4-17 11:53
结束本批处理或本子程序,如第一段代码,第一个goto :eof是结束本批处理运行,第二个goto :eof是结束for循环中本次call调用返回for循环。
Last edited by zw19750516 on 2008-4-17 at 11:56 AM ]
作者: abcd
时间: 2008-4-17 12:58
第二个goto :eof是多余的。
goto :eof
的意思就是转到批处理文件末尾的意思,无其他意思。