本帖最后由 pcl_test 于 2015-10-13 10:21 编辑
批处理源码如下- @echo off
- REM ======================================================================
- REM
- REM Batch File -- Created with SAPIEN Technologies PrimalScript 4.0
- REM
- REM NAME: 批量加密打包单个文件,并生成对应密码表
- REM
- REM AUTHOR: hitme ,
- REM DATE : 2006-12-16
- REM
- REM COMMENT: 密码由随机数字组成,长度与文件名长度相同
- REM
- REM ======================================================================
- @echo off
-
- :repare
- del pass.txt tmp.txt 2>nul
- md package 2>nul
-
- setlocal ENABLEDELAYEDEXPANSION
- :input
- echo.
- set /p input=加密打包文件还是文件夹^(F=文件,D=文件夹,A=全部^)
- echo.
- if /i "%input%"=="f" (set key=/aa) else (
- if /i "%input%"=="d" (set key=/ad) else (
- if /i "%input%"=="a" (set key=) else goto :input))
-
- :code
- for /f "delims=" %%i in ('dir %key%/b^|findstr /v "%~nx0 package"') do (
- echo.%%i>tmp.txt
- echo. >>tmp.txt
- for /f "delims=:" %%a in ('findstr /o "." tmp.txt') do (
- set /a len=%%a - 2
- )
- set m=
- for /l %%l in (1,1,!len!) do (
- echo %random% >nul
- set m=!m!!random:~-1!
- )
- echo %%i:!m!>>pass.txt
- del tmp.txt>nul
-
- )
- endlocal
-
- :package
- setlocal
- set path=%path%;c:\program files\winrar
- if exist pass.txt (
- for /f "tokens=1* delims=:" %%i in (pass.txt) do rar a -p%%j "package\%%~ni.rar" "%%i"
- move pass.txt package
- start package
- ) else echo...未能打包 & pause
- endlocal
复制代码
|