user3378876
user3378876

Reputation: 1924

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

Upvotes: 48

Views: 140816

Answers (5)

Mitul
Mitul

Reputation: 31

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>

Upvotes: 1

Mohammad Rubel
Mohammad Rubel

Reputation: 19

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

Upvotes: 2

Ben Butterworth
Ben Butterworth

Reputation: 28502

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)

Upvotes: 28

Mahmoud Magdy
Mahmoud Magdy

Reputation: 923

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

Upvotes: 1

Alex Telon
Alex Telon

Reputation: 1202

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

Upvotes: 25

Related Questions