Solved

Automatic ZIP of folders using original folder names and contents

Posted on 2007-11-27
2
3,048 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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 …
Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 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

19 Experts available now in Live!

Get 1:1 Help Now