Link to home
Create AccountLog in
Avatar of Sean Still
Sean StillFlag for South Africa

asked on

Zip folders in directory with password

I would like to zip all folders with a password in a specific directory.

Example :

Only the folders that are not yet zipped with the current folder name should be zipped.

c:\temp\Folder1 -> contains still files
c:\temp\Folder2-> contains still files
c:\temp\Folder3-> contains still files
c:\temp\ -> folder is zipped with password already , ignore this folder
Avatar of Mahesh
Flag of India image

This is not possible without 3rd party tools

Also tools won't create separate archiver for every folder underneath

U need to do this manually
Avatar of Sean Still


I dont agree...
this is not possible unless somebody write code / script to traverse each folder and zip it with password for you (that also with some 3rd party software like winzip, WinRAR or 7zip etc)
What you could do is change to that folder and create a list of non zipped folders, something like this:

cd \temp
dir /a:d <folder name pattern>

Can you try the above to get the list only containing Folder1 Folder2 and Folder3?

If so then you could use a for loop with this list and zip each folder using: 7z a <variable>.zip <variable> -pSECRET

When the archive is created correctly (check) then you can add a command to delete the 'source' folder (7z doesn't support a move command).
Avatar of Bill Prew
Bill Prew

Do you have 7zip or some other zip utility installed?  If not, can you install 7zip, and then we can create a BAT script to do what you want using it.

I can install 7zip, I have cirrently winzip installed
This is basically what I am currently doing from my side :

The problem is, in Folder 1 there could be more then one folder.

Each folder should be zipped with it's folder name.

Already zipped folders should be ignored.

cd C:\Temp


set WZZIPPY="C:\Program Files (x86)\WinZip\wzzip.exe"

cd c:\temp\Folder1\                                 
%WZZIPPY% -m %PASS% Archive_%DATE:~0,4%%DATE:~5,2%%DATE:~8, *.txt

Open in new window

Avatar of Bill Prew
Bill Prew

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Did you try my last solution?