Winrar Command Line for separate archives?

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

x51

Thread Starter
Joined
Mar 27, 2008
Messages
1
I need to create a script that will zip all the files in a directory daily.
I also need to put these files into separate archives. (I want each file in it's own Zip / Rar file).

We generally use Winzip Command Line for our archiving, but Winrar has a great feature in the gui "Put files into separate archives". This feature works great when you do it manually with the GUI. The Winrar command line has 2 pages of switches but none appear to cover this feature.

so... the question:

Does anyone know if Winrar can take advantage of the separate archive feature in the command line, or can someone suggest another application that will do this?

I'm not so good with VB or I'd just create a vb script that will process the files one at a time.
 
Joined
Aug 7, 2007
Messages
9,028
You'd think that if you set the Put each file to separate archive setting and saved that as your default profile, that it would work, but it doesn't from a command line. Only works when you drop files in the GUI.

No need for VB, just a simple for statement in a batch file will do the trick.
This little script will do what you want. Just change the paths in blue to be what you need on your system.
Code:
setlocal
set _source=c:\[COLOR="Blue"]<path to folder to backup>[/COLOR]
set _dest=c:\[COLOR="Blue"]<path to folder to store backups>[/COLOR]
set _wrpath=[COLOR="Blue"]C:\Program Files\WinRAR[/COLOR]
if NOT EXIST %_dest% md %_dest%
for %%I in (%_source%\*.*) do "%_wrpath%\winrar" A "%_dest%\%%~[COLOR="DarkRed"]n[/COLOR][COLOR="Magenta"]x[/COLOR]I.rar" "%%I"
This will take file1.txt and create file1.txt.rar
If you don't want the .ext part in the name, remove the x from the For statement.

This will overwrite an archive if it exists, so if you need to save more than one day you can add a date to the backup path (_dest) which will create a new folder for each day, or add the date to each archive name using %date%

HTH

Jerry
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top