50

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.

1
  • Try zip -P password /Volumes/Storage\ 4/archive -p /Volumes/GGZ/faster/mybigfolder/*
    – Costas
    Commented Jan 16, 2015 at 14:26

5 Answers 5

68

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.

1
  • i tried everything else and this worked for me. thanks @bob eager Commented Mar 28, 2020 at 5:29
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.

1
  • 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
    Commented Nov 5, 2018 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/
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.

1
  • Never use ls for script input, that's what find is for.
    – Walf
    Commented Jan 17, 2023 at 4:08
-1

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!!!

You must log in to answer this question.

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