Tag Archives: zip

7zip, Zip, and RAR archive support in Ubuntu Server Tips, Tricks and Tutorials 12 DEC 2013

ubuntu-10-logoUnfortunately the Ubuntu server by default doesn’t come with support for .7z, .zip and .rar archive formats installed, meaning that if you want to work with one of these archives then you’re going to have to add it.

Luckily there are packages available to do the work for you, meaning that you simply need to follow the standard install procedure and you should be good to go:

sudo apt-get install p7zip-full
sudo apt-get install unrar-free

Quick and easy wasn’t it? :)

How to Download Facebook Photo Albums CodeUnit 26 SEP 2011

It is all very well to upload and share your photos with the world on Facebook, but sometimes it is also pretty handy to be able to pull them down again for backup purposes. Enter a brilliant little application that makes it a breeze to download full photo albums from either your own profile, associated groups or liked pages.

Pick&Zip is the fantastically clean and well presented online tool which through it’s flash driven interface allows you to select your own albums or photos where you have been tagged and then download the selected set either as a zip file or as a pdf – directly from your browser! No messy installs to work with whatsoever! :)

To work, it requires that you allow the app to link with your profile, and if you are okay with that, go ahead and log in using the Facebook oauth login system. From there it is a matter of browsing the albums you want to view using the tree on the left, selecting the photos to download and then confirming the download format – as simple as that!

One thing to note though is that thanks to Facebook’s new privacy controls, the application only allows you to download files uploaded by your friends, which makes sense but is a little frustrating if you wanted to say download other people’s albums for more devious purposes (not that you ever would of course!) :P

It is well written, features a great interface and is packaged in a very clean and colourful website, making this definitely one of the premier ways of taking back control of your Facebook photo albums!

Related Link: http://www.picknzip.com

PHP: Easy Function to Create a ZIP File Archive CodeUnit 22 AUG 2011

Borrowing from the always brilliant Mr. David Walsh, here is a great little function to create a zip file archive of a given set of files, ready for download from your site.

First, the zip file create function which will be doing all the heavy lifting:

function create_zip($files = array(), $destination = '', $overwrite = false) {
    //if the zip file already exists and overwrite is false, return false
    if (file_exists($destination) && !$overwrite) {
        return false;
    $valid_files = array();
    //if files were passed in...
    if (is_array($files)) {
        //cycle through each file
        foreach ($files as $file) {
            //make sure the file exists
            if (file_exists($file)) {
                $valid_files[] = $file;
    //if we have good files...
    if (count($valid_files)) {
        //create the archive
        $zip = new ZipArchive();
        if ($zip->open($destination, $overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) {
            return false;
        //add the files
        foreach ($valid_files as $file) {
            $zip->addFile($file, basename($file));
        //echo 'The zip archive contains ',$zip->numFiles,' files with a status of ',$zip->status;
        //close the zip -- done!

        //check to make sure the file exists
        return file_exists($destination);
    } else {
        return false;

Right, now that we have the function, let us set about putting it to use. First, we’ll need an array of fully qualified files to use, for example:

$filestozip = array(

Now we simple run the function, providing it with our array of files to be included, the proposed name of the archive we want to generate, as well as whether or not we should overwrite if it happens to already exist. And if the function returns true, then we can go ahead and link to our newly generated ZIP archive!

$result = create_zip($filestozip,'download.zip',true);
if ($result == true){
echo 'Download!';


What is a .cbr or .cbz File? Comic Books | Software & Sites 15 JUL 2011

You might have come across .cbr or .cbz files during one of your many adventures of trawling through the Internet. What are these mysterious files that Windows doesn’t seem to be able to identify?

Simply put, they are what are know as Comic Book Archive files, something that has become a sort of a de facto standard when it comes to putting out scanned comic books onto the web. Basically all a .cbr or .cbz file is, is a stardard ZIP or RAR archive file (the ‘z’ or ‘r’ at the back gives away which one) containing a number of image files.

These file types are automatically opened by so called comic or manga viewers, and are thus a very useful way for keeping comic books consisting of multiple scanned images in a rather organised fashion.

The Wikipedia entry on the matter lists some useful comic book readers in case you are interested in delving deeper into this little world.

And now you know.

Related Link: http://en.wikipedia.org/wiki/Comic_Book_Archive_file

Ubuntu Server: Maximum Compression of a file Using 7za CodeUnit 28 NOV 2010

Just a quick one-liner to remind me how to ultra compress a file using 7za instead of the bog standard gzip which I always seem to automatically turn to because its the only one I can remember out of my head!

Anyway, the command to ultra compress a single file is:

7za a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on archiveName.7z filetocompress.ext

where the -t7z indicates a 7z archive, -m0=lzma indicates lzma compression method, -mx=9 dicates compression level (9 is ultra), -mfb=64 is the number of fast bytes for LZMA, -md=32m allows for a 32mb dictionary size and -ms=on indicates a solid archive.

Using the above I managed to compress a 285mb SQL dump to a insignificant 7.4mb archived file!


Ubuntu Terminal: How to Quickly GZip a File CodeUnit 01 JUL 2010

File archiving is a particularly simple affair and there are quite a few different archive algorithms to pick and choose from. GZip (.gz) has for long been associated with Linux as one of its main archiving algorithms and so today’s quick command line tip highlights how to quickly create a zipped file on your system.

Simply enter the following to gzip your file:

gzip [filenameToZip] -c -v > [zippedFileName]

Conversly, to unzip a file is as simple as entering:

gunzip [zippedFileName] -c -v > [unzippedFileName]

PHP: Extract a Zip File’s Contents CodeUnit 09 DEC 2009

PHP-logoThe other day I needed to automate the unzipping and processing of files contained within a zip archive. Using the existing PHP Zip library and some help off the web, this is what I was left with:

(Note, you need to enable php_zip.dll extension within php.ini in order to use the code below)

$zip = zip_open($zipfilename);
if ($zip) {
while ($zip_entry = zip_read($zip)) {
$fp = fopen($targetdir . zip_entry_name($zip_entry), "w");
if (zip_entry_open($zip, $zip_entry, "r")) {
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));