|
|
发表于 2011-10-24 16:01:31
|
显示全部楼层
- @goto start
- :help
- @echo.===== Ver: 1.0 =========================== 发布日期: 2011-05-06 =======
- @echo. BAT_NAME: rar最高压缩.bat
- @echo. 返回值:
- @echo. 作用 : rar最高压缩
- @echo. 调用: rar最高压缩.bat [Path...] [file...]
- @echo. [Path]: 文件夹路径
- @echo. [file]: 文件
- @echo. 注: 对于单个文件/夹可以用右键,多个文件/夹请采用拖动方法.
- @echo.====================== Copyright@ by hf-g ========= [彭城] ============
- ping /n 4 127.0>nul
- goto:end
- :start ============================================================
- @echo off
- path=%path%;%~dp0.\..\;%~dp0
- ::==================ADD REG===============================
- for /f "skip=4 tokens=3" %%a in ('REG QUERY "HKLM\Software\hf'file" /v rarMax 2^>nul') do set KEY_v=%%a
- if "%KEY_v%" LSS "1" (
- reg add "HKLM\SOFTWARE\Classes\Directory\shell\rar最高压缩\command" /ve /d ""%~f0" "%%1"" /f>nul
- reg add "HKLM\SOFTWARE\Classes\*\shell\rar最高压缩\command" /ve /d ""%~f0" "%%1"" /f>nul
- reg add "HKLM\Software\hf'file" /v rarMax /d 1 /f>nul
- )
- ::========================================================
- if /i "%~1"=="" goto help
- if /i "%~1"=="-?" goto help
- set "ext="&set "pathname="&set "Dir_name="&set "p_str="
- set /a exit_BL=0,D_count=0,f_count=0
- call:get_P %*
- if "%exit_BL%"=="1" goto end
- ::========================MAIN============================
- ::建立要压缩文件列表
- cd.>"%~dp0.\filelist.txt"
- (
- if not "%pathname_1%"=="" (for /f "tokens=2 delims==" %%a in ('set pathname_') do echo %%a)
- if not "%file_1%"=="" (for /f "tokens=2 delims==" %%a in ('set file_') do echo %%a)
- )>>"%~dp0.\filelist.txt"
- ::确定压缩文件名,调用压缩函数
- if not "%pathname_1%"=="" (
- call:compress "%pathname_1%"
- ) else (
- if not "%file_1%"=="" (
- call:compress "%file_1%"
- ))
- :end ==============================================================
- if exist "%~dp0.\filelist.txt" del/f/q "%~dp0.\filelist.txt"
- exit /b
- ::=================================================================
- :compress <archive_name>
- echo rar最高压缩...
- ::rar u -m5 -inul -ep1 -ed "%~dp1.\%~n1.rar" @"%~dp0.\filelist.txt"
- 7za a -mx=9 -scsWIN "%~dp1.\%~n1.rar" @"%~dp0.\filelist.txt"
- ::7za a -sfx7z_美化版.sfx -mx=9 -scsWIN "%~dp1.\%~n1.exe" @"%~dp0.\filelist.txt"
- :end
- pause
- goto:eof
- ::========================参数设置与获得============================
- :get_p
- ::判断%1是文件夹或文件
- if "%~1"=="" goto:eof
- set "p_str=%~1"
- if exist "%p_str%" (
- if exist "%p_str%." (
- set /a D_count+=1&call set "pathname_%%D_count%%=%p_str%"&call set "Dirname_%%D_count%%=%~nx1"&shift /1&goto get_p
- )
- set /a f_count+=1&call set "file_%%f_count%%=%p_str%"&shift /1&goto get_p
- ) else (
- echo "%p_str%" 不是一个正确的文件夹路径或文件^!&set /a exit_BL=1&shift /1&goto end
- )
- @echo off
- :get_p_end
- goto:eof
- ::======================== 未使用 ============================
- ::获取winrar安装路径,设置rar绝对路径
- For /f "skip=4 tokens=3" %%i in ('Reg Query "HKCR\Applications\WinRAR.exe\shell\open\command" /ve') do (
- echo.%%~i&Set rar_exe=%%~dpi.\rar.exe&call echo.%%rar_exe%%
- )
复制代码 稍作修改即可. |
评分
-
查看全部评分
|