本帖最后由 随风 于 2011-5-28 00:40 编辑
未测试,测试时先做备份。。。- @echo off
- set 源总目录绝对路径=
- set 新总目录绝对路径=
- :loop
- set /a i+=1
- set /a w=!random!%%100000+1
- if defined .%w% set /a i-=1&goto loop
- set n=%n% %w%:
- set .%w%=a
- if %i% lss 20 goto loop
- set cd=%cd%
-
- for /r "%源总目录绝对路径%\" %%i in (.) do (
- if exist "%%i\*.txt" (
- cd/d %%i
- dir/b/s "*.txt">tem1
- findstr /n .* tem1>tem2
- for /f "tokens=1* delims=:" %%a in ('findstr /b "%n%" tem2') do (
- set "m=%%~dpb"&set "wj=%%~nxb"
- setlocal enabledelayedexpansion
- set "h=!m:*%源总目录绝对路径%\=!"
- if not exist "%新总目录绝对路径%\!h!" md "%新总目录绝对路径%\!h!"
- move "!m!!wj!" "%新总目录绝对路径%\!h!!wj!"
- endlocal
- )
- cd/d %cd%
- )
- )
- del /q tem1 tem2
- pause
复制代码
|