17

I have a folder of around 180 GBs, I need to zip it like:

zip -p password /Volumes/GGZ/faster/mybigfolder/* /Volumes/Storage\ 4/archive.zip

But it says:

    zip warning: name not matched: /Volumes/Storage 4/archive.zip

So how do I do this? On another note, archive.zip does not exist, but I'm trying to create it.

  • Try zip -P password /Volumes/Storage\ 4/archive -p /Volumes/GGZ/faster/mybigfolder/* – Costas Jan 16 '15 at 14:26
7

Your command should be:

zip -p password -r /Volumes/Storage\ 4/archive.zip /Volumes/GGZ/faster/mybigfolder/

The manual page (man zip), shows you should have:

zip <options> <archive> <inpath...>

Also, the -r option for recursion is highly recommended over the "*" shell glob for this.

  • Another related pitfall is a simple typing mistake (eg. if you copied the command from one script to another). For example, instead of winzip32.exe -a -r %DEST_PATH%\Output.zip %DEST_PATH%\Output.zip %SOURCE_PATH%\*.*, you accidentally type winzip32.exe -a -r %DEST_PATH%\Output.zip %DEST_PATH%\Output.zip %SOURCE_PATH%\*.*. Note the extra Output.zip...easily done! – AlainD Nov 5 '18 at 12:12
20

This error can also be caused by symbolic links in the directory tree being compressed.

If these don't have correct destinations (perhaps because the directory has been moved or copied from elsewhere), zip will attempt to follow the symlink to archive the target file.

You can avoid this (and also get the effect you probably want anyway, which is not to archive multiple copies of the file) by using the -y (or --symlinks) option.

0

Use the recursive flag (-r) instead of glob (*) to match files to compress. In addition, specify the archive name first and then give the list of files:

zip -p password -r /Volumes/Storage\ 4/archive.zip /Volumes/GGZ/faster/mybigfolder/
0

I've also got this error in the past for a different reason which the -r switch cannot fix. What happened is that I based files to add to the zip with the following bash code/variable

somevar=`ls -1 somedir`

The problem is that ls just lists the files off as if it were in the current directory and this is why zip is complaining (essentially the files do not exist to zip because it is being told to look in the wrong/current directory).

If this is your issue you can correct it like so:

somevar=`ls -1d somedir/*`

As you can see I used the -d switch and also /* at the end of the directory name and then the files were successfully added.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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