Tag Info

Hot answers tagged

137

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) ...


47

It's not built into Windows, but it's in the Resource Kit Tools as COMPRESS, C:\>compress /? Syntax: COMPRESS [-R] [-D] [-S] [ -Z | -ZX ] Source Destination COMPRESS -R [-D] [-S] [ -Z | -ZX ] Source [Destination] Description: Compresses one or more files. Parameter List: -R Rename compressed files. -D Update compressed files only if out of date. -S ...


39

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)


21

Not that I'm aware of. As far as third party tools goes, 7zip has a pretty nice command line interface and the binary can be distributed with your app in the app's directory, so you don't have to rely on it being installed ahead of time.


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.


18

Usually what I do is just upload my files somewhere where they can download stuff from a server. That way, it also doesn't clog up their inbox. If you're short on space, Dropbox is a great service that gives you 2GB of publicly-available space for free (great syncing tools, too!). UPDATE: It seems that I misread your question initially; you were in fact ...


18

Powershell does. See: Compress Files with Windows PowerShell then package a Windows Vista Sidebar Gadget


16

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 = ...


16

You can store symlinks as symlinks (as opposed to a copy of the file/directory they point to) using the --symlinks parameter of the standard zip. Assuming foo is a directory containing symlinks: zip --symlinks -r foo.zip foo/ Rar equivalent: rar a -ol foo.rar foo/ tar stores them as is by default. tar czpvf foo.tgz foo/ Note that the symlink ...


14

I've found luck with sending either a .7z file or sending a FILE.zip.potato . I then instruct the recipient to rename the file back to .zip. It works surprisingly well. You'd think that more email clients/server would check to see what type of file it really is, but I guess the problem isn't sending zip files, it's sending viruses in zip files. If the ...


13

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


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. ...


9

You could try unzip -t zipfile.zip | awk '{print $2}' | tail -n +2 | xargs echo or unzip -t zipfile.zip | awk '{print $2}' | sed 's/zipfile.zip//' | xargs echo and if you have spaces in filenames unzip -l zipfile.zip | tail -n +4 | head -n -2 | awk '{print "\""substr($0,index($0,$4))"\""}' | xargs rm check that the output is sensible and then ...


8

.Net 4.5 has this functionality built in, and it can be leveraged by PowerShell. You'll need to be on Server 2012, Windows 8, or have .Net 4.5 installed manually. [Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem") $Compression = [System.IO.Compression.CompressionLevel]::Optimal $IncludeBaseDirectory = $false $Source = ...


7

You probably want to use zip and not gzip. This should do it: zip -r newzip.zip /path/to/zip/stuff


6

There are numerous file sending services out there that can receive an uploaded file via their web site and will send you a link to go download it. This keeps the strain of handling the file off of the e-mail servers. One such service is SendThisFile.


6

I think you have a social problem, not a technical one. If I'm reading your question right, you have a number of clients who send you (zipped) files from time-to-time, a notable proportion of which can't due to their corporate firewalls. If i have that correct, I would suggest you need to make it clear to your clients that it is their corporate firewall ...


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 ...


6

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 ...


6

SVN repositories are simply files in a directory structure. So the short answer is yes, it is safe !


6

This is not possible. gzip and (pk)zip use different compression formats, and more significantly, zip also packages multiple files, directories, together in one archive.


6

You can use the following option to eliminate the folder/file you want. --exclude=PATTERN Your command becomes like: tar -cvzf /home/backups/$STAMP-Earth.tar.gz --exclude=plugins/dynmap /home/bukkit/


6

This perfectly makes sense for certain hardware: fast CPU, slow disk (HDD not SSD), just one disk. The data has to be read and written. The amount of written data is the same in both cases but reading a compressed file means that less data has to be read. Furthermore it is usually much faster to read a single big file than to read a directory. This effect ...


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

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

There is no 100% solution to this. For instance, my spam/malware probe not only looks at file extension, it also looks at file type. Renaming a zip to .zi_ will not work because it "smells" the zip (looks at the file's structure and fingerprint). Double-extensions are not only reduced to the "inside" extension (again, trapping it by name) but they are ...


5

I have very good experience using 7-Zip. It's open source and does an outstanding job of compression. Lots of formats and strong encryption if you need it. It has both GUI and command line versions.


5

Another solution found on superuser site use windows native com object in .bat file: Can you zip a file from the command prompt using ONLY Windows' built-in capability to zip files?


5

Control-Z likely suspended the ZIP creation. The process is still "running" out there, and has a handle to the data. As long as the file exists and/or someone has it open the space will remain used. You'll have to kill the process (ps, kill, etc..) or bring it to the foreground again and stop it with Control-C (depends on your shell). Then deleting the ...



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