Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extract a .rar file using a batch file

Tags:

batch-file

I am trying to create a batch file which extracts a .rar file using WinRAR to C:\Program Files\

Please help

I tried the following code

set rar=%ProgramFiles%\WinRAR\RAR.exe

set unrar=%programFiles%\WinRAR\UnRAR.exe

and then you compress like this:

"%rar%" a "drop location" "target location"

or decompress like this:

%unrar% e "target location"

but I don't seem to see an option here which shows where the target rar file is. Please help me.

like image 270
user3802901 Avatar asked Sep 17 '25 15:09

user3802901


1 Answers

Check this page: https://cects.com/using-the-winrar-command-line-tools-in-windows/

Basically (taken from that site):

rar a -r yourfiles.rar *.txt c:\yourfolder to compress something

unrar x c:\yourfile.rar *.gif c:\extractfolder\ to uncompress something

The *.txt and *.gif are used for filtering file types and can be omitted.

At the bottom of the page are also links to two example batch files.

like image 101
cnsumner Avatar answered Sep 23 '25 05:09

cnsumner