[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2016-08-04
13
Medium Priority
?
91 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
11 Comments
 
LVL 24

Assisted Solution

by:Eirman
Eirman earned 500 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 99

Assisted Solution

by:John Hurst
John Hurst earned 500 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 25

Assisted Solution

by:NVIT
NVIT earned 500 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 59

Assisted Solution

by:Bill Prew
Bill Prew earned 500 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
 
LVL 24

Assisted Solution

by:Eirman
Eirman earned 500 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 24

Accepted Solution

by:
Eirman earned 500 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 59

Assisted Solution

by:Bill Prew
Bill Prew earned 500 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 25

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 99

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

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.
Suggested Courses
Course of the Month17 days, 22 hours left to enroll

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