Solved

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

Posted on 2016-08-04
13
55 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 92

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 52

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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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 52

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 92

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Running VB/Batch script through Group policy 30 79
Win 7 - Devices and Printers folder doesn't populate 10 25
Compile Error 7 41
Server Error 11 47
First some basics on Windows 7 Backup.  It has 2 components one is a file based backup which is stored in .zip files each zip is split at around 200 Megabytes and there is the Image Backup which is as the name implies a total image of the partition …
While working, an annoying popup showing below will come and we cannot cancel or close it form the screen. The error message will come again and again.
In this Micro Tutorial viewers will learn how to use Boot Corrector from Paragon Rescue Kit Free to identify and fix the boot problems of Windows 7/8/2012R2 etc. As an example is used Windows 2012R2 which lost its active partition flag (often happen…
This Micro Tutorial will go in depth within Systems and Security in Windows 7 and will go into detail regarding Action Center, Windows Firewall, System, etc. This will be demonstrated using Windows 7 operating system.

895 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

12 Experts available now in Live!

Get 1:1 Help Now