Avatar of Gucci_Rey
Gucci_Rey
 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\Folder4.zip -> folder is zipped with password already , ignore this folder
PowershellScripting LanguagesMicrosoft DOS* winzip

Avatar of undefined
Last Comment
Bill Prew

8/22/2022 - Mon
Mahesh

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
Gucci_Rey

ASKER
I dont agree...
Mahesh

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)
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Gerwin Jansen

What you could do is change to that folder and create a list of non zipped folders, something like this:

c:
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).
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.

~bp
Gucci_Rey

ASKER
I can install 7zip, I have cirrently winzip installed
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Gucci_Rey

ASKER
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 /p PASS="PASSWORD"

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

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

Open in new window

ASKER CERTIFIED SOLUTION
Bill Prew

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Bill Prew

Did you try my last solution?

~bp