Tuesday, April 14, 2009

Quick Bytes: Unzipping ZIP file using Powershell

 

Quick Bytes: Unzipping ZIP file using Powershell

UNZIP.ps1

$zipfilename=”C:\myfolder\myzip.zip";                        # Replace with source ZIP file
$destination=”C:\myfolder\unzipped";                         # Replace with target folder

    if(test-path($zipfilename))                                     # Test if the zip file exists
    {   
        $shellApplication = new-object -com shell.application
        $zipPackage = $shellApplication.NameSpace($zipfilename)
        $destinationFolder = $shellApplication.NameSpace($destination)
        $destinationFolder.CopyHere($zipPackage.Items())
    }

    else
   {
       echo "The source ZIP file does not exist";
   }

Published Tuesday, April 14, 2009 8:28 PM by ssehgal

The Deployment guy : Quick Bytes: Unzipping ZIP file using Powershell

7 comments:

Alexis said...

Obviously in the world there tool which better than winzip,and to my mind this is next application-zip file check,it is better works with zip files and it resources wider as far as I can see than winzip,also it has free status as how as I remember,software permits to repair corrupted archives with *.zip extension,solve errors on example-CRC error and Cannot open file: it does not appear to be a valid archive,program for check repair zip file and check integrity of zip file uses several different algorithms for crc check fix zip file and data recovery, that is why, the process will take some time, according to CPU performance and file size,program will work under all supported versions of this operating system,will keep initial structure of your archive as well as original names of files and directories,check repair zip file can check why zip file is corrupted and work with password protected archives, but you should know this password.

Alex said...

My experience advises in this condition use next tool-repair broken zip file,because it has many pluses,such as program is free as far as I can see,has many resources,and it can save a lot of free space on your HDD, when applied to files, that are used rarely,program is so easy to use, that it does not require any technical skills, anyone, who knows Windows interface, can work with this tool,supports Windows 98, Windows Me, Windows NT 4.0, Windows 2000, Windows XP, Windows XP SP2, Windows 2003 and Windows Vista,program is very powerful, it contains several different algorithms, developed in our company, for accurate data recovery,repair zip file broken and repair broken zip file does not modify source file during the process, so, you can take it and try to recover with any other Zip repair service and compare the results.

brendenm said...
This comment has been removed by the author.
brendenm said...
This comment has been removed by the author.
Alex said...

One day I unpacked my zip files and unexpectedly the light switched off. My data were lost. I decided to use the Inet. For luck I stumbled across there - how do i work on my corrupt zip files. The software solved my proposition quite hands down and I didn't waste the money.

Gavin S said...

might be better to parameterize the script ?

param (
[Parameter(mandatory=$true)][string] $zipfilename, #source ZIP file
[Parameter(mandatory=$true)][string] $destination #target folder
)
if(test-path($zipfilename)) # Test if the zip file exists
{
$shellApplication = new-object -com shell.application
$zipPackage = $shellApplication.NameSpace($zipfilename)
$destinationFolder = $shellApplication.NameSpace($destination)
$destinationFolder.CopyHere($zipPackage.Items())
}

else
{
echo "The source ZIP file does not exist";
}

mark said...

http://stackoverflow.com/questions/2359372/powershell-copyhere-if-it-already-exists-work-around

Blog Archive