- @echo off
- cd /d "%~dp0"
- for %%A in (*.txt) do (
- call :randomFileName 10 "%%A"
- )
- pause
- exit /b
- :randomFileName
- setlocal EnableDelayedExpansion
- ::---------生成随机文件名。
- ::---------%1为密码长度,%2为原文件名。
- if "%~1"=="" goto :eof
- if %~1 lss 1 goto :eof
- if "%~2"=="" goto :eof
- set wordset=abcdefghijklmnopqrstuvwxyz0123456789
- set password_len=%1
- set return=
- ::---------------------------循环
- :loop
- set /a "numof=%random%%%36"
- set return=%return%!wordset:~%numof%,1!
- set /a password_len-=1
- if %password_len% gtr 0 goto loop
- ::---------------------------循环
- if exist "%return%%~x2" goto randomFileName
- echo ren %2 "%return%%~x2"
- ren %2 "%return%%~x2"
- endlocal
- goto :eof
复制代码
|