1.

Solve : Create batch to archive files using main folder name for archive name?

Answer»

I am trying to create BATCH file and couldn't find solution anywhere on the web.
I would like to archive (winrar) folder&subfolders (eg.Folder A in C:\Temp\A). Folder A has a bunch of subfolders & files.
I am using this command :

"C:\Program Files\WinRAR\WinRAR.exe" a -esh -m5 -mt2 -r -s -t "ZZZZ.rar"

Problem is that I would like archive to be named same as the name of the main folder (in this case folder"A" - A.rar), and archive to be send to

folder C:\Temp (up one level).

Thank you so much.I looked online and found a winrar archiver... I have never USED this, but its worth checking into.
http://www.rarlab.com/shop2rarlab-index.php?prod=winrar&x-source=winraronlyThis will echo the command that should WORK. Remove the echo to test it.

Code: [SELECT]@echo off
cd /d "c:\temp\a"
for /f "delims=" %%a in ("%cd%") do (
echo "C:\Program Files\WinRAR\WinRAR.exe" a -esh -m5 -mt2 -r -s -t "..\%%~nxa.rar"
)
pauseIt works! Thank you so much for your help.



Discussion

No Comment Found