Tag Info

Hot answers tagged

133

This is how you can do it purely from Powershell without any external tools. This unzips a file called test.zip onto the current working directory: $shell_app=new-object -com shell.application $filename = "test.zip" $zip_file = $shell_app.namespace((Get-Location).Path + "\$filename") $destination = $shell_app.namespace((Get-Location).Path) ...


32

Now in .NET Framework 4.5, there is a ZipFile class that you can use like this: [System.Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem') [System.IO.Compression.ZipFile]::ExtractToDirectory($sourceFile, $targetFolder)


18

DotNetZip will allow you to do this from PowerShell. It is not a one-liner, but the library will allow you to write the PowerShell script you need. You can also use the COM interface, see Compress Files with Windows PowerShell then package a Windows Vista Sidebar Gadget. Googling "zip powershell" or "unzip powershell" might also turn up useful results.


18

You may wish to check out The PowerShell Community Extensions (PSCX) which has cmdlets specifically for this.


15

While a zip file is in fact a container format, there's no reason why it can't be read as a stream if the file can fit into memory easily enough. Here's a Python script that takes a zip file as standard input and extracts the contents to the current directory or to a specified directory if specified. import zipfile import sys import StringIO data = ...


11

This is unlikely to work how you expect. Zip is not just a compression format, but also a container format. It rolls up the jobs of both tar and gzip.bzip2 into one. Having said that, if your zip has a single file, you can use unzip -p to extract the files to stdout. If you have more than one file, there's no way for you to tell where they start and stop. ...


11

If you've got Java on the box, you can use jar xf test.zip


6

What you want to do is, make unzip take a ZIPped file on its standard input rather than as an argument. This is usually easily supported by gzip and tar kind of tools with a - argument. But the standard unzip does not do that (though, it does support extraction to a pipe). However, all is not lost... Look at funzip manual page. funzip without a file ...


5

You need to pass in the flag (16) Respond with "Yes to All" for any dialog box that is displayed. Like so: $destination.Copyhere($zip_file.items(), 16) You may want to combine that with this flag: (4) Do not display a progress dialog box. So you would do: $destination.Copyhere($zip_file.items(), 20)


5

I find the simplest solution to just use infozip binaries which I have used for years and use in a UNIX environment. PS> zip -9r ../test.zip * PS> cd .. PS> unzip -t test.zip Archive: test.zip testing: LinqRepository/ OK testing: LinqRepository/ApplicationService.cs OK testing: LinqRepository/bin/ OK ... No errors ...


5

I also like Info-ZIP (the Zip engine found in most other Zip utilities) and 7-Zip, another favorite which has both a GUI and command line Zip utility. The point being, there are some good command-line utilities that will work for most PowerShell tasks. There are some tricks to running command line utilities that were not built with PowerShell in mind: ...


5

Identical MD5 hashes suggest that the transfer has worked well. More than 2G filesize sounds suspiciously like some pointer size issue - maybe the zip in question doesn't handle that well? more than (ca) 2G would be a negative number in 32 bit... Can you unzip the file on the system where you zipped it? Do both systems differ? Is one 64bit, the problematic ...


4

It's not possible with Info-Zip which is the most common OSS implementation. More importantly though, it's not recommended due to the constructs of ZIP archives. If a change of format is viable to you then consider using tar(1) instead. It is quite happy with streamed input/output and, in fact, expects it by default. Additionally you can often tell whether ...


4

no need to use external basename for file in *zip do unzip -d "${file%.zip}" "$file" done


4

for zip in *.zip; do 7z x "$zip" done


4

Try the -j option. From the man page: -j junk paths. The archive's directory structure is not recreated; all files are deposited in the extraction directory (by default, the current one).


3

Running Plesk Panel 9.5.2 on CentOS If you think that's relevant you may have problems understanding what's going to be involved. First you need to find the files you need to copy - $ which unzip Will list the executable file you need to copy into their $PATH. You'll also need to check that this is not a symbolic link or a wrapper script: $ file ...


3

The way you did it was that your local machine was doing the actual unzipping, just against data that was remote - what you need to do is run the unzip code on the remote server via something like RDP/VNC/SSH or similar - you need full access to the remote machine via one of these protocols first though ok.


3

unzip -o hi.zip me/\* -d /home/zzz should do the trick. I suggest you test it first to make sure you don't overwrite the wrong files.


3

for x in *.zip; do unzip -d "$(basename "$x" .zip)" "$x"; done


3

You can filter the output with grep. Here I'm telling grep to hide all rows that contain a slash '/' and anything after the slash: zipinfo file.zip | grep -v "/."


3

I haven't tried this, but, there's a zipfile module in Python's standard library since version 1.6, and since version 2.6 has had an extractall method You should be able to do something like: Create a file with the following contents (editing it to fit your use case). Save the file as "unzipfile.py" Run with python unzipfile.py And it'll extract ...


2

You could use this code snippet for a .vbs file (VBScript): Function WindowsUnZip(sUnzipFileName, sUnzipDestination) Set oUnzipFSO = CreateObject("Scripting.FileSystemObject") If Not oUnzipFSO.FolderExists(sUnzipDestination) Then oUnzipFSO.CreateFolder(sUnzipDestination) End If With CreateObject("Shell.Application") ...


2

Your script works fine for ZIP files: Get-ChildItem $spath -include *.zip -Recurse I'm not sure why you're using: -include *.xlsx as this is excluding your archive files. If you want to move XLSX files then you'll need to write another block of code to handle the file move.


2

I wonder if this has something to do with the internals of Powershell job steps in SQL Agent. For example you cannot do write-host in powershell job step in SQL Agent as explained in this blog post: http://blogs.msdn.com/b/mwories/archive/2009/09/30/the-use-of-write-host-and-sql-server-agent-powershell-job-steps.aspx One suggestion-- try setting up a ...


2

I finally ended up rolling my own rpm's for unzip 6, they can be found here: http://www.noodles.net.nz/2011/02/15/unzip-6-for-rhel-5-6/


2

I've found good success with 7-zip, it appears they have a fedora core build as well that might work for you, the downloads can be found at http://www.7-zip.org/download.html. Failing the fedora one, you can download the source and/or binary and try that.


2

Solution: ls -1 *.zip | xargs -L 1 7z x Explanation: ls -1 *.zip outputs a one-column list of zip files to stdout (ls dash-one, not ls dash-ell) xargs -L 1 takes each filename returned and passes it to 7z x as a parameter.


2

I don't believe there are other ways of unzipping the file on a system without unzip, but you could send the file to another linux system (with unzip installed or root access available), unzip the file there and - if necessary - send the unzipped file back to the original server. The command to send a file from one server to another is scp. The syntax to ...


2

If you have java installed, the jar command can unzip a zipped file: jar xvf file.zip Note that you can install java without root access: http://docs.oracle.com/javase/7/docs/webnotes/install/linux/linux-jdk.html



Only top voted, non community-wiki answers of a minimum length are eligible