在命令行批处理文件中使用rar.exe压缩文件

时间:2013-09-25 06:31:20

标签: batch-file cmd compression updates winrar

我将单个文件update.ver压缩到update.rar 在命令行中使用rar.exe(批处理文件) 字典大小1024KB 请帮我制作这个批处理文件

@echo off
REM Path to WinRAR executable in Program Files
set path="C:\Program Files\WinRAR\Rar.exe";%path%



echo 1. Compress files in dir individually (no subdirs)
echo.
echo.
set /P
if "%FILE%"=="1" goto indiv


REM Compress files in directory individually (no subdirectories)
:indiv
echo.
echo.
FOR %%i IN (*.*) do (
rar a "%%~ni" "%%i"
)
goto eof


:eof


endlocal

Erase v6.rar
Erase update.ver
rename update.rar update.ver

此代码在Windows vps中不起作用

1 个答案:

答案 0 :(得分:1)

一些示例代码:

@echo off &setlocal
REM Path to WinRAR executable in Program Files
set "path=C:\Program Files\WinRAR;%path%"

echo 1. Compress files in dir individually (no subdirs)
echo(
echo(
set /P "answer="
if not "%answer%"=="1" goto eof

REM Compress files in directory individually (no subdirectories)
:indiv
echo(
echo(
FOR %%i IN (*) do (
    rar a "%%~ni.rar" "%%~i" || echo Error building archive!
)

Erase v6.rar
Erase update.ver
rename update.rar update.ver
相关问题