1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Winrar Command Line for separate archives?

Discussion in 'All Other Software' started by x51, Mar 27, 2008.

Thread Status:
Not open for further replies.
  1. x51

    x51 Thread Starter

    Mar 27, 2008
    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.
  2. TheOutcaste


    Aug 7, 2007
    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.
    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%


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 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/697666

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice