48

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.

Braiam
  • 35,991
DisplayName
  • 11,688

5 Answers5

66

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.

Eddie C.
  • 429
Bob Eager
  • 3,600
15

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.

Danny Staple
  • 2,161
  • 1
  • 15
  • 22
  • 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 05 '18 at 12:12
1

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/
53c
  • 111
  • 1
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.

Eddie C.
  • 429
0

We normally type:

zip -r [file_name.zip] [file_name]

try this way:

zip [file_name.zip] [file_name] -r

and then type in the initial syntax:

zip -r [file_name.zip] [file_name]

Amazingly it worked for me!!!

tinlyx
  • 678