14

I'm extracting a zip (self-extracting, but that probably doesn't matter) and for a few files I'm getting a dialog asking me if I want to replace a file that was already extracted with a file that's just about to be extracted. At first glance I didn't understand how a zip could contain the same file in the same place more than once. I then browsed to the file in question using 7zip (or any tool) and found this:

enter image description here

The difference is in the block number. What's actually happening here?

5 Answers 5

10

Yes, the ZIP file format allows multiple files with the same name. Files in a ZIP aren't actually in directories but simply have a long name that optionally includes the path. And files are added to the ZIP by effectively concatenating them end to end. The only place where synonyms cause a problem in the ZIP format is with the directory, where presumably the later file replaces the earlier one. But when an entire ZIP file is extracted (vs. extracting individual files) the general approach is to ignore the directory and just extract the files in the order they appear in the ZIP.

The image shown is, of course, of the ZIP file contents, not a Windows directory.

6

Yes. .zip files CAN contain the same file twice. This can be accomplished using the "add to archive" function of your zip tool. By default, a later file overwrites any former file(s) when extracting as this is usually the desired behavior.

Also, files that differ only by the case of their filename/path are considered identical when extracting to a filesystem that is case insensitive (Windows or Mac OS.)

1
  • Filesystems on Linux and some configurations of macOS are case-sensitive, and so ZIP files have to be case-sensitive as well.
    – Flimm
    Dec 9, 2020 at 14:50
2

Looks like you are using Windows which considered two files with names differing by case alone to be the same filename.

It may be that your archive was created on a case-sensitive file-system (such as most Linux ones) and the two files had different cases (Ex: ENTRIES, Entries, entries).

If you look at the output, the files have the same size, same date, same CRC, so these file are identical, you can safely overwrite one with the other. It may be that some copied it with a different case as a local temporary backup while working on those files. The block number is that they are stored in different locations in the zip file, which should be obvious.

0

Same file, same extension (or in this case, no extension). As has been said above this can be caused by manually adding multiple files to the zip file, because the internal structure of the zip file is not really a folder. It can also be caused when the zip file is created on a system that is case-sensitive such as Linux, and is being opened on a file system that is case-insensitive such as Windows.

Note that on Windows if you drag-and-drop to extract files a collision like this will actually appear to lock up the GUI. You don't have to resort to killing the task and restarting though; this is a known bug in 7-Zip and you can use the keyboard still to navigate through the options (e.g. Replace All) even though the mouse is locked -> http://sourceforge.net/p/sevenzip/bugs/1509/

-3

You can't have two identical file names in the same path. Have you checked to see if your system is hiding the extensions? That could be the possible difference between the two. Maybe one is a backup file.

2
  • Same file (with extension, which happens to be blank) same path. Please see the screenshot flickr.com/photos/46007162@N03/5278220416 - it shows the same file but as two different blocks. I am not sure what that means.
    – Howiecamp
    Dec 20, 2010 at 19:39
  • 2
    As stated elsewhere, a zip archive CAN contain the same file twice. Dec 4, 2017 at 12:53

You must log in to answer this question.

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