Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

From 7zip I've downloaded their command line tool 7za.exe, and I have to following script:

echo off


set zip ="C:\7za.exe"

set filename="%date%.backup.zip"

set pathtobackup="C:\MyDocs"

%zip% -t7z %filename% %pathtobackup%\*.doc

My intention is to backup all the doc files in MyDocs folder (including subfolders) and put them in a dated zip file. Afterwards I will move this file with robocopy to my server, but at the moment Im having some problems getting it to zip the files.

Anyone have a clue? Anyway I can append a password for the file too?

share|improve this question
You're "having some problems": care to elaborate? At a first glance, you're creating a .7z archive with a .zip extension. Also, you're relying on the %date% variable which may contain invalid, reserved characters. –  and31415 Mar 5 at 9:54
add comment

1 Answer 1

up vote 1 down vote accepted

Use the syntax

7z a -tzip archive.zip -r src\*.cpp src\*.h

so in your case, it'd be

7z a -t7z %filename% -r %pathtobackup%\*.doc

Source: http://sevenzip.sourceforge.jp/chm/cmdline/switches/recurse.htm

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.