Solved

Looking for a way to quickly "zip" files from multiple folders

Posted on 2016-08-04
13
51 Views
Last Modified: 2016-09-17
I do a weekly task that has been very tedious and I was looking for a way to maybe make it more efficient. I work in the GIS Field and there is a folder that we get updates from an outside contractor. I was tasked with updating our cloud mapping application but the only way it takes updates is to upload zip files of the "shapefiles." Up to now I have had to go into each individual folder and archive each component of the shape file folder by folder. I was wondering if there was a way where I can run a tool or a script that would automatically zip all the folder contents using the filename of the shapefile. I posted images that will hopefully clear up what I am trying to accomplish.
Directory full of the updated foldersInside each individual fold, Have to archive the files in each folder
0
Comment
Question by:GravitaZ24
  • 3
  • 2
  • 2
  • +2
13 Comments
 
LVL 23

Assisted Solution

by:Eirman
Eirman earned 125 total points (awarded by participants)
ID: 41742710
I have a few ideas but I need some info .....
By shapefile, I presume you mean the name of a folder and you want to rename the contents to include the name of the folder and then to zip up the contents..
0
 
LVL 90

Assisted Solution

by:John Hurst
John Hurst earned 125 total points (awarded by participants)
ID: 41742717
I suggest you look at the WinZip Command Line Support Add-On which will allow you to zip up the files by command line.

http://kb.winzip.com/kb/entry/125/

Try that.
0
 
LVL 23

Assisted Solution

by:NVIT
NVIT earned 125 total points (awarded by participants)
ID: 41742851
For specific code that runs winzip against desired folders, this does it:
Make a .bat file with this code.

Note: I can't see your whole source folder. Please correct it below.

@echo off
setlocal enabledelayedexpansion

set SourceDir=c:\m4data\m4 reports\esriexport\esriexport2

pushd %SourceDir%
for /d %%a in (*) do (
  "c:\program files\winzip\wzzip" -r -P "%%~na" "%%a\*.*"
)
popd

Open in new window

0
 
LVL 51

Assisted Solution

by:Bill Prew
Bill Prew earned 125 total points (awarded by participants)
ID: 41742898
If you don't already own WinZip, then I would recommend 7Zip as a better choice for script driven archiving.  It can be found here, but a few questions before I build a script that tries to meet your needs.

In your screen captures, it looks like the .SHP files are already some type of archive and contain multiple files, including a ZIP file?  So can you clarify, what folder(s) are the files you need to zip, what files need to be zipped, what the name of the zip file(s) should be, where the zip files should be placed, etc.  The more detail and description you can provide, the sooner we can get to a working approach.

~bp
0
 

Author Comment

by:GravitaZ24
ID: 41742941
I apologize if I didn't give enough info.
The result I need is demonstrated by the second image. The "Shapefile" consists of 4 of the components, the .shp, .prj, .shx, and .dbf. The archive file in the image is just what I was trying to accomplish.
Each one of the folders in the first image contains those 4 components of the "shapefile" and I need an archive of those 4 components in a zip file for each folder. It is hard to explain but I hope that helps.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 23

Assisted Solution

by:Eirman
Eirman earned 125 total points (awarded by participants)
ID: 41743096
This shows how to create multiple zip files of multiple folders with 7zip
http://www.wikihow.com/Use-7Zip-to-Create-Multiple-Compressed-Folders-in-One-Go
It creates a batch file which you can modify for future use.
0
 
LVL 23

Accepted Solution

by:
Eirman earned 125 total points (awarded by participants)
ID: 41743137
I found a better solution with no scripting !!!
Use WinRar with this option
Files To Separate Archive Option
I normally use RAR because it's more secure  - You can use zip if requires.

The Put each file to separate archive option actually mis-worded.
It puts every file in a folder into a single zip or rar archive.

You can create a "Profile" for this task on the General Tab of WinRar
So ... Select your folders ..... right click and choose "Add to archive" .... choose your profile .... OK
All your zip files will be created in one go!
0
 
LVL 51

Assisted Solution

by:Bill Prew
Bill Prew earned 125 total points (awarded by participants)
ID: 41743185
Okay, here is a BAT approach that uses the 7-zip utility I mentioned earlier to get the job done.  Save as a BAT file and adjust the SET statements near the top as needed.  I made some assumptions, like you would want to skip folders that already had the ZIP in them, and I displayed info as it processed, perhaps more than you want, but easy to comment out ECHO statements once you test it fully.  Let me know if this meets your needs, and what questions you have.

@echo off
setlocal

rem Define folder to process and location of 7-zip exe file
set BaseDir=B:\EE\EE28961498\Files
set ZipExe=c:\_pf\7-zip\7z.exe

rem If base directory not found quit
if not exist "%BaseDir%\" (
  echo.*ERROR* - Base directory not found [%BaseDir%].
  exit /b
)

rem If zip program not found quit
if not exist "%ZipExe%" (
  echo.*ERROR* - Zip program not found [%ZipExe%].
  exit /b
)

rem process each folder under the base folder
for /d %%D in ("%BaseDir%\*.*") do (

  rem Skip any folders that already have a ZIP in them
  if exist "%%~D\%%~nD.zip" (
    echo *WARNING* - ZIP file [%%~D\%%~nD.zip] already exists, skipping folder.
  ) else (
    rem ZIP desired folders into a ZIP file in this folder
    echo *INFO* - Creating ZIP file [%%~D\%%~nD.zip].
    "%ZipExe%" a "%%~D\%%~nD.zip" "%%~D\*.dbf" "%%~D\*.prj" "%%~D\*.shp" "%%~D\*.shx" -tzip 1>NUL
  )

)

Open in new window

~bp
0
 
LVL 23

Expert Comment

by:NVIT
ID: 41794969
Multiple workable solutions were posted. I suggest an even split between the experts
John Hurst ID: 41742717
NVIT ID: 41742851
Eirman ID: 41743137
Bill Prew ID: 41743185
0
 
LVL 90

Expert Comment

by:John Hurst
ID: 41795061
As suggested by experts
0
 

Author Comment

by:GravitaZ24
ID: 41798484
Sorry for the delay, I used a combination of the WinRAR approach and the BAT Script. Also got some help from this program. http://www.bulkrenameutility.co.uk/Main_Intro.php
Bulk Rename Utility
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum editing capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

705 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