Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2016-08-04
13
Medium Priority
?
90 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
[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
  • 3
  • 2
  • 2
  • +2
13 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 98

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 58

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 58

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 98

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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
This Micro Tutorial will teach you how to change your appearance and customize your Windows 7 interface to your unique preference. This will be demonstrated using Windows 7 operating system.
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.

636 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