1.

Solve : Encrypt zip files within a batch file and then email?

Answer»

I just installed WINZIP 16.0 and the WZZIP DOS utility. I have dozens of FILES I need to ENCRYPT using predefined passwords. The format for the WZZIP file is:

WZZIP -s[password] filename.zip filename

What I would like to do is create a batch file to zip all Excel files in the current directory with the password listed in a file. So far I've worked out that I can zip all the files like this:

FOR /f %%f IN ('dir /b *.xls') DO ( WZZIP %%~nf.zip %%f )

but how do I add the password (-s) option with the file's respective password? I can PUT the password in a *.txt file (e.g. TEST.TXT could contain the password for the TEST file) or a common password file that has all target file names in the first column and their respective passwords in the second column or whatever is required.

Once that is all done, I need to email each zipped, passworded file to a matching email recipient.

Suggestions?No, I don't have the solution .
Some suggestions.
Break the problem into steps.
It is not necessary to do bath in a one-line command.
How many files do you have? Does this have to be done often?
Are the passwords ALREADY in list?

Here is a simple way make a list of all XLS files in the directory.
Quote

dir *.xls /b >mylist.txt
You could edit that file by hand and add the passwords.

Doing part of the work by hand is quicker that taking three days to find a clever batch program to do the whole think in one whack.Don't know if batch is capable of e-mailing files, but you can use:

Code: [Select]@echo off
set /p path=Enter the Path to the Folder you Wish to Zip:
cd %path%
if exist password.txt set /p p=<password.txt
if "%p%"=="" WZZIP zip.zip *.xls & exit
WZZIP -s[%p%] zip.zip *.xls

this should take the password from the first line in 'password.txt' that is located in the folder you wish to zip. If there is no password.txt it will not put a password in. Assuming that WZZIP can use wildcards. otherwise you will need to do something a little more elaberate, will post that later.

Code: [Select]@echo off
setlocal EnableDelayedExpantion

dir *.xls /b >mylist.txt
set /p p=<password.txt
for /f %%G in (mylist.txt) do (WZZIP -s[%p%] zip.zip %%G)
Is the OP still looking for a solution?I don't Know, hasn't posted.


Discussion

No Comment Found