我想对当前目录下的文本文件进行随机的命名,可是遇到一个问题,只能对一个文本进行重命名,而其它的则不变
@echo off
set /a b=%random%%%100+1
for /r %%a in (*.txt) do (
set /a c=%random:~0,2%
ren %%~dpnsa.txt %c%.txt)
pause
[ Last edited by icyheart on 2007-9-7 at 06:27 PM ]
[ Last edited by icyheart on 2007-9-7 at 05:11 PM ]作者: icyheart 时间: 2007-9-7 17:05 @echo off
set /a b=%random%%%100+1
:start
for /r %%a in (*.txt) do (
set /a c=%random:~0,2%
if %%~na neq %c% (ren %%~dpnsa.txt %c%.txt) else goto start)
pause
这样也不行作者: knoppix7 时间: 2007-9-7 18:21 %~XX不叫变量扩展延迟..
@echo off
setlocal ENABLEDELAYEDEXPANSION
set /a b=%random%%%100+1
for /r %%a in (*.txt) do (
set /a c=!random:~0,2!
ren %%~dpnsa.txt !c!.txt)
pause作者: icyheart 时间: 2007-9-7 18:26 想出来啦这样的应该是
@echo off
setlocal ENABLEDELAYEDEXPANSION
for /r %%a in (*.txt) do (
set c=!random!
ren %%~dpnsa.txt !c!.txt)
pause