How to compress each subfolder in a folder into a separate RAR archive using WinRAR?

adamzso picture adamzso · Jul 24, 2014 · Viewed 11.9k times · Source

I am really new to batch file coding and need your help.

I've these directories:

c:\rar\temp1\xy.jpg
c:\rar\temp1\sd.jpg
c:\rar\temp1\dd.jpg

c:\rar\temp2\ss.jpg
c:\rar\temp2\aa.jpg
c:\rar\temp2\sd.jpg

c:\rar\temp3\pp.jpg
c:\rar\temp3\ll.jpg
c:\rar\temp3\kk.jpg

And I want to compress them to this

c:\rar\temp1\temp1.rar
c:\rar\temp2\temp2.rar
c:\rar\temp3\temp3.rar

How could this be done using WinRAR?

Answer

Mofi picture Mofi · Jul 24, 2014

This can be done also with WinRAR without using a batch file, not exactly as requested, but similar to what is wanted.

  1. Start WinRAR and navigate to folder c:\rar\.
  2. Select the folders temp1, temp2 and temp3 and click on button Add in the toolbar.
  3. As archive name specify now the folder for the RAR archive, for example c:\rar\.
  4. Switch to tab Files and check there the option Put each file to separate archive.
  5. Click on button OK.

WinRAR creates now 3 RAR archives with the file names temp1.rar, temp2.rar and temp3.rar in folder c:\rar\ with each archive containing the appropriate folder with all files and subfolders.

The list of files to add can be changed also on tab Files by entering for example *.txt in Files to exclude to ignore text files in those 3 folders on creating the archives.

And finally it makes sense to enter *.jpg on tab Files in edit field below Files to store without compression as JPEG files usually contain already compressed data and therefore WinRAR cannot really compress the data of the files further.