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
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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_ReyAuthor Commented:
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)
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Gerwin Jansen, EE MVETopic Advisor Commented:
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).
Bill PrewIT / Software Engineering ConsultantCommented:
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.

Gucci_ReyAuthor Commented:
I can install 7zip, I have cirrently winzip installed
Gucci_ReyAuthor Commented:
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

Bill PrewIT / Software Engineering ConsultantCommented:
Based on your explanations so far this feels like it should be what you described.  It looks for all folders in the starting folder, and if there isn't a zip file already with that folder name it will zip that folder.

@echo off

rem Define base folder and path to command line zip utility
set BaseDir=c:\temp\Folder1
set wzzip=C:\Program Files (x86)\WinZip\wzzip.exe

rem Prompt for password, if not entered exit
set Pass=
set /p Pass="Password:"
if "%Pass%" EQU "" exit /b

rem Change to desired base folder, if unsuccessful exit
pushd "%BaseDir%"
if /i "%CD%" NEQ "%BaseDir%" exit /b

rem Loop over first level folders in base folder
for /d %%A in (*.*) do (

  rem Only zip files if not already a zip with this folder name
  if not exist "" (

    rem Zip first level files in this folder
    "%wzzip%" -s%Pass% "" *.*



rem Return to current folder when script started

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bill PrewIT / Software Engineering ConsultantCommented:
Did you try my last solution?

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.