Link to home
Start Free TrialLog in
Avatar of antonioking
antoniokingFlag for United Kingdom of Great Britain and Northern Ireland

asked on

zip sub-folders in folder using script

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
Avatar of antonioking
antonioking
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

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

ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Bill
Your script is better as it waits for each folder to be zipped before moving to the next one.
Avatar of Bill Prew
Bill Prew

Welcome, thanks for the feedback.

~bp