A way to zip/unzip zip files in PowerShell?

J

Jon Miller

I don't know if this is totally a PowerShell question or not, but, basically
what I'm wondering is if there is a way to zip/unzip files using PowerShell?
A way to do this via the command-line IMHO has been long overdue. I always
use Info-Zip for this, but, I was thinking that it would be nice if this
functionality was built-into the OS. I know .NET has classes for
compressing/uncompressing files, but, at least as of .NET 2.0, it seemed to
lack classes for dealing with things at a higher level. i.e. handling the
format of the archive file. It would be great of .NET 3.0 had this
functionality.

Jon
 

My Computer

G

Greg Borota

I always find InfoZip way faster than Windows Zip folders. Anybody, any idea
why zip folders are so painfully slow?
You could probably use COM or DLL calls to get to Windows Zip folders
functionality but I prefer InfoZip over it, given the reason above.

Greg

"Jon Miller" <> wrote in message
news:[email protected]
>I don't know if this is totally a PowerShell question or not, but,
>basically what I'm wondering is if there is a way to zip/unzip files using
>PowerShell? A way to do this via the command-line IMHO has been long
>overdue. I always use Info-Zip for this, but, I was thinking that it would
>be nice if this functionality was built-into the OS. I know .NET has
>classes for compressing/uncompressing files, but, at least as of .NET 2.0,
>it seemed to lack classes for dealing with things at a higher level. i.e.
>handling the format of the archive file. It would be great of .NET 3.0 had
>this functionality.
>
> Jon
>
>
 

My Computer

A

Alex K. Angelopoulos [MVP]

One of the more useful community projects IMO would be writing .NET wrapper
classes for the 7-Zip or InfoZip DLLs, with the associated cmdlets. A zip
provider would be nice, but wouldn't necessarily give much more bang for the
buck in everyday use.

"Greg Borota" <[email protected]> wrote in message
news:%[email protected]
>I always find InfoZip way faster than Windows Zip folders. Anybody, any
>idea why zip folders are so painfully slow?
> You could probably use COM or DLL calls to get to Windows Zip folders
> functionality but I prefer InfoZip over it, given the reason above.
>
> Greg
>
> "Jon Miller" <> wrote in message
> news:[email protected]
>>I don't know if this is totally a PowerShell question or not, but,
>>basically what I'm wondering is if there is a way to zip/unzip files using
>>PowerShell? A way to do this via the command-line IMHO has been long
>>overdue. I always use Info-Zip for this, but, I was thinking that it would
>>be nice if this functionality was built-into the OS. I know .NET has
>>classes for compressing/uncompressing files, but, at least as of .NET 2.0,
>>it seemed to lack classes for dealing with things at a higher level. i.e.
>>handling the format of the archive file. It would be great of .NET 3.0 had
>>this functionality.
>>
>> Jon
>>
>>

>
>
 

My Computer

?

=?Utf-8?B?ZHJlZXNjaGtpbmQ=?=

Info-ZIP has some nice command line tools.
I build myself a simple wrapper around zip.exe that I use for folder backups.
It adds a time stamp and a comment to the name of the zip file and prompts
for encryption. So if anyone is interested:


function zip-dir($directory) {
if ($directory -eq $null) {
$directory = read-host "Directory"
}

$comment = read-host "Comment"
$dateformat = ".yyyy-MM-dd.HH-mm-ss."
$name = $directory + (Get-Date).toString($dateformat) + $comment + ".zip"

$encrypt = read-host "Encrypt"

if ($encrypt.length -gt 0) {
$start = Get-Date
zip -r -S -e $name $directory
$end = Get-Date
} else {
$start = Get-Date
zip -r -S $name $directory
$end = Get-Date
}
Write-Host "TotalSeconds: $(($end-$start).TotalSeconds)"
}

--
greetings
dreeschkind

"Greg Borota" wrote:

> I always find InfoZip way faster than Windows Zip folders. Anybody, any idea
> why zip folders are so painfully slow?
> You could probably use COM or DLL calls to get to Windows Zip folders
> functionality but I prefer InfoZip over it, given the reason above.
>
> Greg
>
> "Jon Miller" <> wrote in message
> news:[email protected]
> >I don't know if this is totally a PowerShell question or not, but,
> >basically what I'm wondering is if there is a way to zip/unzip files using
> >PowerShell? A way to do this via the command-line IMHO has been long
> >overdue. I always use Info-Zip for this, but, I was thinking that it would
> >be nice if this functionality was built-into the OS. I know .NET has
> >classes for compressing/uncompressing files, but, at least as of .NET 2.0,
> >it seemed to lack classes for dealing with things at a higher level. i.e.
> >handling the format of the archive file. It would be great of .NET 3.0 had
> >this functionality.
> >
> > Jon
> >
> >

>
>
>
 

My Computer

?

=?Utf-8?B?ZHJlZXNjaGtpbmQ=?=

Mow also had a post on this on his fabulous blog a while ago, but his script
might need some minor adjustments since it is for an older PowerShell release:

http://mow001.blogspot.com/2006/01/msh-out-zip-function.html

--
greetings
dreeschkind

"Greg Borota" wrote:

> I always find InfoZip way faster than Windows Zip folders. Anybody, any idea
> why zip folders are so painfully slow?
> You could probably use COM or DLL calls to get to Windows Zip folders
> functionality but I prefer InfoZip over it, given the reason above.
>
> Greg
>
> "Jon Miller" <> wrote in message
> news:[email protected]
> >I don't know if this is totally a PowerShell question or not, but,
> >basically what I'm wondering is if there is a way to zip/unzip files using
> >PowerShell? A way to do this via the command-line IMHO has been long
> >overdue. I always use Info-Zip for this, but, I was thinking that it would
> >be nice if this functionality was built-into the OS. I know .NET has
> >classes for compressing/uncompressing files, but, at least as of .NET 2.0,
> >it seemed to lack classes for dealing with things at a higher level. i.e.
> >handling the format of the archive file. It would be great of .NET 3.0 had
> >this functionality.
> >
> > Jon
> >
> >

>
>
>
 

My Computer

O

/\\/\\o\\/\\/

Jon Miller wrote:
> I don't know if this is totally a PowerShell question or not, but, basically
> what I'm wondering is if there is a way to zip/unzip files using PowerShell?
> A way to do this via the command-line IMHO has been long overdue. I always
> use Info-Zip for this, but, I was thinking that it would be nice if this
> functionality was built-into the OS. I know .NET has classes for
> compressing/uncompressing files, but, at least as of .NET 2.0, it seemed to
> lack classes for dealing with things at a higher level. i.e. handling the
> format of the archive file. It would be great of .NET 3.0 had this
> functionality.
>
> Jon
>
>


You can use the Zipfolder support of shell.application COM object :

http://mow001.blogspot.com/2006/01/msh-out-zip-function.html

Greetings /\/\o\/\/
 

My Computer

J

Jon Miller

Thanks, that's pretty cool. However, relying on old COM code somehow doesn't
appeal to me. IMHO, Microsoft, should have managed code libraries for
dealing with zip files. Otherwise, we might risk the code running too fast
without a huge memory footprint. ;-)

Jon

"/\/\o\/\/" <[email protected]> wrote in message
news:[email protected]
> Jon Miller wrote:
>> I don't know if this is totally a PowerShell question or not, but,
>> basically what I'm wondering is if there is a way to zip/unzip files
>> using PowerShell? A way to do this via the command-line IMHO has been
>> long overdue. I always use Info-Zip for this, but, I was thinking that it
>> would be nice if this functionality was built-into the OS. I know .NET
>> has classes for compressing/uncompressing files, but, at least as of .NET
>> 2.0, it seemed to lack classes for dealing with things at a higher level.
>> i.e. handling the format of the archive file. It would be great of .NET
>> 3.0 had this functionality.
>>
>> Jon
>>
>>

>
> You can use the Zipfolder support of shell.application COM object :
>
> http://mow001.blogspot.com/2006/01/msh-out-zip-function.html
>
> Greetings /\/\o\/\/
>
>
 

My Computer

B

Bob Weiner

Considering that Office 2007 will used compressed xml as the native file
type, it seems that there should be a managed code option. You can bet that
there will be several linux libraries!

bob


"Jon Miller" <[email protected]> wrote in message
news:[email protected]
> Thanks, that's pretty cool. However, relying on old COM code somehow
> doesn't appeal to me. IMHO, Microsoft, should have managed code libraries
> for dealing with zip files. Otherwise, we might risk the code running too
> fast without a huge memory footprint. ;-)
>
> Jon
>
> "/\/\o\/\/" <[email protected]> wrote in message
> news:[email protected]
>> Jon Miller wrote:
>>> I don't know if this is totally a PowerShell question or not, but,
>>> basically what I'm wondering is if there is a way to zip/unzip files
>>> using PowerShell? A way to do this via the command-line IMHO has been
>>> long overdue. I always use Info-Zip for this, but, I was thinking that
>>> it would be nice if this functionality was built-into the OS. I know
>>> .NET has classes for compressing/uncompressing files, but, at least as
>>> of .NET 2.0, it seemed to lack classes for dealing with things at a
>>> higher level. i.e. handling the format of the archive file. It would be
>>> great of .NET 3.0 had this functionality.
>>>
>>> Jon
>>>
>>>

>>
>> You can use the Zipfolder support of shell.application COM object :
>>
>> http://mow001.blogspot.com/2006/01/msh-out-zip-function.html
>>
>> Greetings /\/\o\/\/
>>
>>

>
>
 

My Computer

J

Jason Gurtz

Jon Miller wrote:
> Thanks, that's pretty cool. However, relying on old COM code somehow doesn't
> appeal to me. IMHO, Microsoft, should have managed code libraries for
> dealing with zip files. Otherwise, we might risk the code running too fast
> without a huge memory footprint. ;-)


LOL! Reading this just made my day. :) Old Skool all the way baby!

~Jason

--
 

My Computer

Top