CODE: [Copy to clipboard]
:: RarExt.bat - 为WinRAR添加分别压缩功能
:: Will Sort - 17:38 2005-3-27 - WinXP
:: 2005-4-1 3'rd Updated
@echo off
if %0=="%ProgramFiles%\WinRAR\RarExt.bat" goto Compress
:Configure
if not exist "%ProgramFiles%\WinRAR\Rar.exe" echo 未找到WinRAR,无法进行设置! & goto end
if exist %0 copy %0 "%ProgramFiles%\WinRAR\RarExt.bat">nul
if exist %0.bat copy %0.bat "%ProgramFiles%\WinRAR\RarExt.bat">nul
if not exist "%ProgramFiles%\WinRAR\RarExt.bat" echo 批处理 RarExt.bat 创建失败! & goto end
reg add HKCR\*\shell\CompressRespectivelyWithRAR /ve /t REG_SZ /d "分别压缩当前所有文件(夹)为RAR文件(&Y)" /f>nul
if errorlevel 1 echo 注册表修改失败! & goto end
reg add HKCR\*\shell\CompressRespectivelyWithRAR\command /ve /t REG_SZ /d "%ProgramFiles%\WinRAR\RarExt.bat" /f>nul
if errorlevel 1 echo 注册表修改失败! & goto end
reg add HKCR\Folder\shell\CompressRespectivelyWithRAR /ve /t REG_SZ /d "分别压缩此文件夹下所有文件(夹)为RAR文件(&Y)" /f>nul
if errorlevel 1 echo 注册表修改失败! & goto end
reg add HKCR\Folder\shell\CompressRespectivelyWithRAR\command /ve /t REG_SZ /d "%ProgramFiles%\WinRAR\RarExt.bat \"%%L\"" /f>nul
if errorlevel 1 echo 注册表修改失败! & goto end
echo 成功设置 WinRAR 分别压缩选项,可在文件或文件夹的右键菜单使用此功能!
pause
goto end
:Compress
for /d %%d in (%1.\*.*) do "%ProgramFiles%.\WinRAR\rar" a -r -inul %1.\"%%~nxd.rar" "%%~nxd"
for %%f in (%1.\*.*) do "%ProgramFiles%.\WinRAR\rar" a -r -inul %1.\"%%~nf.rar" "%%~nxf"
:end