Solved

Automatic ZIP of folders using original folder names and contents

Posted on 2007-11-27
2
3,139 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 Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Disk Performance 100% 5 89
PSTOOLS Office Activation Not Working 11 120
Is there a simple front-end menu system. 9 105
how to run this deletion request 4 30
The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

830 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