Solved

Automatic ZIP of folders using original folder names and contents

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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

770 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