Batch- Archiving files into a .rar

September 16, 2010 at 16:32:34
Specs: Windows XP
I was wondering if it was possible to move files into a .rar or a .jar archive using batch.
I tried using this, but it corrupted the archive:
copy "%CD%\file.txt" "%CD%\archiveone.jar"
copy "%CD%\file.txt" "%CD%\archivetwo.jar"

I also tried searching for a solution, but I couldn't find one. Is it possible to do this?

See More: Batch- Archiving files into a .rar

Report •

September 16, 2010 at 16:37:43
as far as I know, Windows doesn't support rar files natively. A free program that will do it though is 7-Zip.

Report •

September 16, 2010 at 16:41:41
I went ahead and explored my WinRAR directory, and found Rar.exe and Rar.txt.
Rar.txt contained the following:

RAR <command> [ -<switches> ] <archive> [ <@listfiles...> ]
[ <files...> ] [ <path_to_extract\> ]

Command line options (commands and switches) provide control of
creating and managing archives with RAR. The command is a string (or a
single letter) which commands RAR to perform a corresponding action.
Switches are designed to modify the way RAR performs the action. Other
parameters are archive name and files to be archived into or extracted
from the archive.

I copied Rar.exe into the folder containing my .bat file and changed the code to

rar u "archiveone.jar" "file.txt"
rar u "archivetwo.rar" "file.txt"

It said that they were bad archives.

Report •
Related Solutions

Ask Question