Tag Archives: compression

How to Gzip Files on Windows

7-Zip can be used to create more than 7z compressed files, it can also create GZip compressed files and directories. GZip can compressed a single file on its own, however if you need to compress a directory an extra step is required where the directory is first archived with the help of tar and then compressed with GZip. This tutorial will cover single file compression and directory compression.

First Things First

Download 7zip from http://www.7-zip.org/ and install the application.

Gzip Single File

Start the 7zip application and browse the location where the file you want to compress is located.

Right click on the file_name > 7-Zip > Add to archive…

Gizp Windows

For Archive format: select gzip and click on OK to start compressing.

Gzip Windows

Compression progress.

Gzip Windows

The file is now compressed.

Gzip Windows

Gzip Directory

Compressing a directory takes an extra step, first you need to create a tar of the directory you want to compress.

Gzip Windows

Select the source directory > 7-Zip > Add to archive…

Gzip Windows

For Archive format: select tar and click on OK.

Gzip Windows

Progress being displayed.

Gzip Windows

Once again go back to 7-Zip select the new tar file(filename.tar) > 7-Zip > Add to archive…

Gzip Windows

For Archive format select gzip and click on OK.

Gzip Windows

Progress being displayed.

Gzip Windows

The resulting compressed directory with the new extension ending in .tar.gz.

Gzip Windows

Conclusion

While GZip files may not be all that common in Windows they are commonly used in other operating systems like Linux and FreeBSD. This post is specially useful since many Linux installation only have support for GZip, including support for Zip and 7z is not even an option. If you have any questions feel free to leave a comment below.

Links

Homepage: http://www.7-zip.org/

Ubuntu: How to Create and Open Zip Files from the Command Line

If you have an Ubuntu/Debian server installation and need to open or create Zip file then you need to install the necessary packages to work with Zip files. Fortunately, we can easily add support for Zip to our installation by installing two packages(Zip, Unzip) both available from the repositories.

Note: This post assumes you have the ability to install packages, root or sudo access.

Creating a Zip Archive

Install Zip from the repositories.

# apt-get install zip

The entire process is quite simple to understand.

# zip -r new-file-name.zip directory-to-compress/
  • zip – This is the name of the application we will be using to compress
  • -r – Short for Recursive, only use this option is you are creating a compressed archived from a directory
  • new-file-name.zip – Name of the resulting compressed archive, the naming is up to you
  • directory-to-compress/ – Name of the directory we are about to compress

It is possible to add more than one directory in to the same archive.

# zip -r new-file-name.zip directory-1/ directory-2/

But, what if I only need to compress a single file. Similar process except we don’t need to use the -r(recurse) option.

# zip report.zip LitenDuplicateReport.csv

Opening a Zip archive

Opening or extracting the contents from a compressed archive is handled not by the Zip package but by a second package called Unzip.

# apt-get install unzip

With Unzip you have two options as to how the contents will be extracted, either you can extract the contents of the compressed archive to a directory or simply extract the contents to the current directory.

# unzip nc111nt.zip -d netcat/
  • unzip – Tool that will extract contents from Zip compressed archive
  • nc111nt.zip – Name of the archive we are extracting from
  • -d – Short for destination
  • netcat – Unzip will create a new directory called netcat where the contents will be extracted to

Or you can extract the contents of the archive to the current directory you are in.

# unzip nc111nt.zip

Conclusion

All you need is two packages and your installation will be able to work with Zip archives. I know Ubuntu/Debian have support for Gzip but if you work with Windows users and need to share files with them then Zip might be the only way to go.

Split Files With 7-Zip

For some reason I don’t see many people making use of the file spliting option in the 7-Zip File Manager. By splitting I mean dividing a larger file into multiple smaller files, later those files can be restored to its original state. Splitting files is useful in the case where large files have to be distributed but without the risk of having a large file download fail which would mean starting all over again.

This post assumes 7-Zip is already installed.

Benefits:

  • Did I say no cost, 7-Zip is free.
  • File sharing sites that impose limits on the size of the files users can upload.
  • Areas where poor Internet connectivity are common.
  • For example, a 1GB file is split into 4 x 250MB files. In the event of an interruption it would takes less time to restart a failed 250MB download than it would be for 1GB download.
  • Better chance of downloading files without the risk of corruption.
  • Compression or no compression can be specified.

Downside:

  • Some people might not understand the 7-Zip File Manager interface at first.

Some files are not worth compressing since they are already compress like in the case of media files, text files on the other hand should definetely be compressed.

When manually entering the the size of the resulting split place the “M” after the number.

File Splitting

7-Zip File Manager can be easily accessed from the Context Menu by right clicking on the file you wish to work with. Click on Add to archive….

For testing purposes I make use of 10GB file, I could go with the default split options but I rather specify my own size. In the Split to volume, bytes: box I entered 500M which means the 10GB file with be split in to 21 x 500MB. And click on OK.

Depending on the type of compression selected(or none) the process may take a considerable amount of time.

The result is one 10GB file split in to 21 Files.

File Restore

Restoring the split files in to its original format is straight forward. Select all files and click on 7-Zip > Extract files…

You can either change the path where the resulting file will extracted to or go with the defaults, when done click on OK.

Depending on the size of the file be prepared to wait for the file to be decompressed and put back together.

Hopefully, this tutorial will proved useful. Leave a comment if necessary just understand that it may take some time before I can answer.

Meet 7-Zip

Once in a while I receive large files as in 4GB archives compressed using ZIP, yes it’s compression but no the best kind. ZIP brings limitations and by that I mean large files can not be effectively compressed. The right compression method can make a difference between waiting 60 minutes or 20 minutes for a download to complete.

If this is your problem then you should give 7-Zip a try. 7-Zip is a file archiver licensed under GNU. Some of it’s features are: cross platform, support for multiple CPUs, capability to encrypt files, can extract a number of other formats, and is efficient at compressing large files to a reduced size. 7-Zip can be used from both command line or GUI. The front-end for 7-Zip in Linux is File Roller.

7-Zip archive

What makes 7-Zip special:

  • High compression ratio in new 7z format with LZMA compression
  • Supported formats:
    o Packing / unpacking: 7z, ZIP, GZIP, BZIP2 and TAR
    o Unpacking only: ARJ, CAB, CHM, CPIO, DEB, DMG, HFS, ISO, LZH, LZMA, MSI, NSIS, RAR, RPM, UDF, WIM, XAR and Z.

  • For ZIP and GZIP formats, 7-Zip provides a compression ratio that is 2-10 % better than the ratio provided by PKZip and WinZip
  • Strong AES-256 encryption in 7z and ZIP formats
  • Self-extracting capability for 7z format
  • Integration with Windows Shell
  • Powerful File Manager
  • Powerful command line version
  • Plugin for FAR Manager
  • Localizations for 74 languages

7-Zip can be resource intensive, specially heavy on the CPU. However, smaller files mean more space available and less time transferring them.

Links