Solved

Automatic ZIP of folders using original folder names and contents

Posted on 2007-11-27
2
3,222 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
In this article we have discussed the manual scenarios to recover data from Windows 10 through some backup and recovery tools which are offered by it.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

717 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