Solved

zip sub-folders in folder using script

Posted on 2014-01-22
4
999 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
  • 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 51

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 51

Expert Comment

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

~bp
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

706 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

19 Experts available now in Live!

Get 1:1 Help Now