We help IT Professionals succeed at work.

Zip folders in directory with password

156 Views
Last Modified: 2018-02-15
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
Comment
Watch Question

MaheshArchitect
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
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

Author

Commented:
I dont agree...
MaheshArchitect
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
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)
Gerwin JansenTopic Advisor
CERTIFIED EXPERT
Most Valuable Expert 2016

Commented:
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 PrewTest your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016

Commented:
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

Author

Commented:
I can install 7zip, I have cirrently winzip installed

Author

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 /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

Test your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Bill PrewTest your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016

Commented:
Did you try my last solution?

~bp

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions