Solved

Zipping Multiple Folders using 7z

Posted on 2011-03-14
5
435 Views
Last Modified: 2012-05-11
Hi Guys,

I got hundreds of folders in one directory

Path : I:\sourcefiles\

Folders Names as followed

WE_20110130
WE_20110129
WE_20110128
WE_20110127
WE_20110126

so on....

I want to zip this folder with exact name using 7zip to different directory using script

example to

I:\DestinationZipFiles\

Followed by zip files


WE_20110130.zip
WE_20110129.zip
WE_20110128.zip
WE_20110127.zip
WE_20110126.zip


My 7Zip exe is located in C:\Program Files\7-zip\7z.exe

Any help thanks

D
0
Comment
Question by:Dreamslogic
  • 3
  • 2
5 Comments
 
LVL 13

Accepted Solution

by:
soostibi earned 250 total points
ID: 35133596
What about this PowerShell solution?
Get-ChildItem I:\sourcefiles | ForEach-Object {
    Start-Process -FilePath "C:\Program Files\7-Zip\7z.exe" -ArgumentList "a -r -tZIP I:\DestinationZipFiles\$($_.name) $($_.fullname)\*.*"
}

Open in new window

0
 

Author Comment

by:Dreamslogic
ID: 35134043

I am sorry but it didn't worked. It doesn't do anything !
0
 
LVL 13

Expert Comment

by:soostibi
ID: 35136213
For me it works like a charm! Do you copied the code correctly?
Does the 'Get-ChildItem I:\sourcefiles' part give any result?
Do you get any error messages?
0
 

Author Comment

by:Dreamslogic
ID: 35413389
Ok
0
 

Author Closing Comment

by:Dreamslogic
ID: 35413392
Worked !!
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

856 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