1

I have a curl cronjob which periodically downloads a bunch of zip files into a target folder. Like this:

curl www.zipdownloadfile.com/file.zip > file.zip

Now I need to have Ubuntu unzip all of the zip files in that target folder.

What's the proper command which will unzip all of the files in a target destination/folder?

Thanks

1

thats your command man this will unzip all zip file in a destination file

find /path-to-folder -name '*.zip' -exec unzip -d destination_folder {} +

Just try it .

0

The issue here is that unzip *.zip doesn't work for some reason. I guess the unzip doesn't accept wildcard path arguments for files.

Nux's answer is good but I use a slightly different version of the find command. If you cd into the folder you've downloaded all the zip files then you can just run:

find . -type f -name "*.zip" -exec unzip {} \;

This will search the current working directory and all sub-directories recursively with ., then find only files, -type f, then search for anything named *.zip with-nameand it will execute unzipexec unzipand substitute the result of the search which is the full file name and place it with{}after the unzip command as the argument.\;` is just magical syntax to say 'I'm done the command is finished.'.

This still worked for me in Ubuntu 16.04 to unzip all files in the current directory after downloading a huge number.

A similar command can also used to unrar a set of rar files you've downloaded simultaneously as well:

find . -type f -name "*.rar" -exec unrar x -e {} \;

The above magical command will search all files in the current directory and all folders and files recursively in sub-directories to find all files that end in .rar and then unrar them directly to the current working directory.

Let's say you want to unpack a bunch of stuff that you've just recently downloaded:

Fri Nov 17 10:56 AM Downloads: tree .
.
├── download1
│   ├── show01.r00
│   ├── show01.r01
│   ├── show01.r02
│   └── show01.rar
├── download2
│   ├── movie01.r00
│   ├── movie01.r01
│   ├── movie01.r02
│   ├── movie01.r03
│   └── movie01.rar
└── download3
    ├── program01.r00
    ├── program01.r01
    ├── program01.r02
    ├── program01.r03
    └── program01.rar

3 directories, 14 files

This is only a small example you could have 20 or even 40 different foldedrs each containing their own master .zip file or .rar file that needs to be unrar'd. Doing a CD into each individual download directory to use 'unrar' is both time consuming and wasteful. Just use the find command!

sudo apt-get install unzip
sudo apt-get install unrar
cd ~/Downloads
find . -type f -name "*.rar" -exec unrar x -e {} \;
find . -type f -name "*.zip" -exec unzip {} \;

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.