Solved

zip sub-folders in folder using script

Posted on 2014-01-22
4
1,036 Views
Last Modified: 2014-01-23
I'd like a script to zip each sub-folder in a folder.
Then delete the folder.

My folder contains 1589 sub-folders, and i'd like each folder zipped and then the original folder deleted.

I'd be grateful for any help
Regards
0
Comment
Question by:antonioking
[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
  • 2
4 Comments
 

Author Comment

by:antonioking
ID: 39799941
I've managed to create the script myself...
Dim strFolder, subfolder, folder, strMessage

strFolder = "<FOLDERPATH>"
Set folder = CreateObject("Scripting.FileSystemObject").GetFolder(strFolder).SubFolders

Dim oShell
Set oShell = WScript.CreateObject ("WScript.Shell")

For Each subfolder in folder
	oshell.run """C:\Program Files (x86)\7-Zip\7z.exe"" a -r " & strFolder & "\" & subfolder.name & ".zip " & strFolder & "\" & subfolder.name & "\*"
Next

Open in new window

0
 
LVL 56

Accepted Solution

by:
Bill Prew earned 500 total points
ID: 39799984
Here's a small BAT approach if you have 7zip (or download it).

@echo off
setlocal EnableDelayedExpansion

set z=c:\program files\7-zip\7z.exe
set BaseDir=c:\base
set DestDir=d:\dest

for /D %%D in ("%BaseDir%\*.*") do (
  "%z%" a -tzip "%DestDir%\%%~nD.zip" "%%~D\*.*"
  rd /q /y "%%~D"
)

Open in new window

~bp
0
 

Author Closing Comment

by:antonioking
ID: 39802432
Thanks Bill
Your script is better as it waits for each folder to be zipped before moving to the next one.
0
 
LVL 56

Expert Comment

by:Bill Prew
ID: 39805038
Welcome, thanks for the feedback.

~bp
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
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 …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

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