Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to compress 80.000 files into multiple zip files. This is the command I use:

zip -s 200M photos_test/*

However I get the following error:

-bash: /usr/bin/zip: Argument list too long

What can I do to solve the issue, beside manually splitting the folder files ?


share|improve this question
The error -bash: /usr/bin/zip: Argument list too long may cause in to case: 1- because of not using -r switch, 2- there too many files for archiving. So in first case @Mat's answer is true and in the second case the @IgnacioVazquez-Abrams's answer is true. – shgnInc Jul 6 '14 at 6:57
up vote 5 down vote accepted

If you want the whole directory, you could simply use the -r switch:

zip -r -s 200M myzip photos_test

That will include all subdirectories of photos_test though.

share|improve this answer
+1, would have suggested the same thing – slhck Apr 19 '11 at 9:03
I've done what you suggest and I have a small (7mb) and the segments (200mb each). However, I cannot unzip the content, I'm running unzip unix but I get "bad zipfile offset (lseek)". Furthermore, I need to extract them in Windows environment as well, and there I only have Windows 7 extractor I guess. – Patrick Apr 19 '11 at 10:08
those are different questions, open another question for that (link to this one for reference). make sure you post the names of the generated zip files (not all of them, but first and last at least), and the exact command line you use. – Mat Apr 19 '11 at 10:11
find photos_test/ -mindepth 1 -maxdepth 1 | zip -@ -s 200M
share|improve this answer

The problem seems to be the expansion of the "*". Use folder name or ".":

If you want to include the root folder within the zip:

zip -r folder_with_80k_files

If you don´t want to include the root folder inside the zip:

cd folder_with_80k_files
zip -r .
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .