'zip error - Nothing to do

I try to zip all folders in given directory. So I wrote this

find /home/user/rep/tests/data/archive/* -maxdepth 0 -type d -exec zip -r "{}" \;

but got

zip error: Nothing to do! (/home/user/rep/tests/data/archive/tmp.zip)

zip error: Nothing to do! (/home/user/rep/tests/data/archive/tmp_dkjg.zip)

here is what this contains

user@machine:~$ ls /home/aliashenko/rep/tests/data/archive/
tmp  tmp_dkjg  tmp_dsf


Solution 1:[1]

The issue is that you have not provided a name for the zip-files it will create.

find /home/user/rep/tests/data/archive/* -maxdepth 0 -type d -exec zip -r "{}" "{}" \;

This will create separate zipped directories for each of the subfolders tmp tmp_dkjg and tmp_dsf

Solution 2:[2]

To create a zipfile:

  • From a list of files, zip myZippedImages.zip alice.png bob.jpg carl.svg. You need to specify both

    • the zipfile (output), and
    • the files you will zip (input).
  • From a folder, zip -r myZippedImages.zip images_folder


To make it clearer than Alex's answer, to create a zip file, zip takes in a minimum of 2 arguments. How do I know, because when you use man zip, you get its man page, part of which is:

zip  [-aABcdDeEfFghjklLmoqrRSTuvVwXyz!@$] [--longoption ...]  [-b path]
       [-n suffixes] [-t date] [-tt date] [zipfile [file ...]]  [-xi list]

and when you typed zip in the command line, you get:

zip [-options] [-b path] [-t mmddyyyy] [-n suffixes] [zipfile list] [-xi list]

In both cases, notice [zipfile list] or [zipfile [file ...]]. The square brackets indicate something being optional. If you're not saving to a zipfile, then the list argument is not required.

If you want to save into a zipfile (choosing the [zipfile list] option, you need to also provide list, because it is within the square brackets. For this reason, I prefer the output of zip instead of man zip. (The man page might be confusing)

Solution 3:[3]

If you used zip command on a zip file you will see that error. make sure you are using zip on none zip version file, otherwise use unzip

Solution 4:[4]

I tried below command

find /home/user/rep/tests/data/archive/* -maxdepth 0 -type d -exec zip -r "{}" "{}" \;

but got this,

find: ‘/home/Mitul/rep/tests/data/archive/*’: No such file or directory

Then i provided the name of zip file and it created the zip file,

zip -r <NAME FOR THE ZIP FILE WHICH WILL BE CREATED> <NAME OF THE FOLDER OR FOLDERS OR FILE OF WHICH YOU WANT TO MAKE A ZIP FILE>

Solution 5:[5]

Follow the steps :

  1. Use root user to confirm permissions
  2. cd to the folder location
  3. Use command zip -r [zip_file_name] [folder_name]/

Note: Do not use .zip with your zip file name. Also make sure you have zip and unzip installed by using apt or yum install zip and unzip

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2
Solution 3 Mahmoud Magdy
Solution 4 Mitul
Solution 5 Mohammad Rubel