Solved

Automatic ZIP of folders using original folder names and contents

Posted on 2007-11-27
2
3,082 Views
Last Modified: 2013-12-01
I have multiple folders, for example

folder1
folder2
folder3

and in each folder there are hundreds of jpeg images

I need something that will Automatically ZIP every folder including contents into single ZIP files of the same name, no compression is necessary.

ex:
folder1.zip
folder2.zip
folder3.zip

As an added bonus, it would be great if it was possible for it to delete the old files.

Does anyone know if there is a program or a really intuitive script that would automate this task for me?
0
Comment
Question by:kfstout
2 Comments
 
LVL 38

Accepted Solution

by:
Shift-3 earned 500 total points
ID: 20360161
7-Zip is a good free zipping program which accepts command-line parameters.
http://www.7-zip.org

You could install 7-Zip and then use a batch file like the one below to automate the creation of zip files.

Copy the script below into a new file with a .cmd extension.  Customize the value of the "root" variable with the location of the folder which contains the folders to be zipped.  Running the script should zip each of the folders into a separate file.

For safety I have put an echo command on Line 12 in front of the rd command which deletes the folders after zipping.  Please test this script in a non-production environment before removing the echo.


@echo off

setlocal
 

REM Location of 7z.exe

set exe=c:\program files\7-zip\7z.exe
 

REM Location of root folder

set root=c:\folders
 

for /F "tokens=* usebackq" %%G in (`dir "%root%" /A:D /B`) do (

 "%exe%" a -tzip "%root%\%%G.zip" "%root%\%%G" -mx0 > NUL

 if exist "%root%\%%G.zip" echo rd /s /q "%root%\%%G"

)
 

endlocal

Open in new window

0
 

Author Closing Comment

by:kfstout
ID: 31411209
OUTSTANDING!!!

This is perfect!  MUCH appreciated
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Good afternoon all, We are running a VM infrastructure on a clustered ESX environment with two DELL R710's.  One of our IT Application Support Engineers contacted me and asked if it was possible to extend the partition of a certain Windows 2003 S…
A while back when OPSMGR 2012 was released we were very excited about getting it into our environment and upgrading our 2007 implementation,  we started our planning and we then proceeded with our implementation. All went as planned & our system …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now