windows - How to Unzip files recursively in Linux / DOS

23
2014-04
  • Murtaza

    I have a zipped folder which contains thousands of zipped folders contained in itself and that goes down the hierarchy, I have to unzip each and every file and place it in a single folder.

    This task is platform independent either in linux or on windows.

    Your help would be highly appreciated. Thankyou.

  • Answers
  • macrojames

    I tried it the quick and dirty way and it worked for me. Create a script:

    #!/bin/bash
    function rec_unzip {
    unzip $1 && rm $1
    for i in $(find . -name "*.zip"); do
        if [ -f $i ]
        then
             rec_unzip $i
        fi
    done
    }
    rec_unzip $1
    

    execute the script with ./script_name.sh first_zip_file.zip.

    You are free to modify it to supply target directories to unzip.


  • Related Question

    How to unzip a windows-built .tar.gz in linux?
  • takpar

    i wanna transfer files from my windows pc to linux server.

    suppose i have a file structure like this:

    img /
        logo.gif
    css /
        style.css
    index.php
    

    i tar.gz the directory, then upload, and then tar-xvzf the uploaded file. but the result is 3 file in root like this:

    img\logo.gif
    css\style.css
    index.php
    

    when i use zip instead of tar.gz it breaks the structure. i.e. it unzip some directories as empty files. fr examples it makes an empty file named img.

    what's the reliable solution to transfer files between windows and linux?


  • Related Answers
  • Daenyth

    To me that looks like the tool you're using on windows is broken. A tarball is a tarball and the OS you make it on should not matter.

    I recommend using p7zip though, on windows.

    If you're more concerned with just moving the files, winscp is a nice GUI over scp. If your linux box is running sshd you can just transfer them over the network.