I have a zip file which contains multiple files that have the same filename (and there are no subfolders). These are in fact different files: they have unique sizes and content, and are "duplicates" in name, only. My question is, how can I extract them all without one overwriting another? Neither WinRAR nor PowerArchiver seems able to do this automatically (both stop after only extracting three files, unless I say it's OK to overwrite). If I manually extract the files one at a time, it only extracts the most recently added file with a given name; yet I know, based on the overall size of the archive, that the data for the other files is in there. So I tried renaming the files while still in the zip (I copied the zip first); it took 10 minutes to rename one file, and ended up renaming both (though the unique sizes were retained)! I am at a loss as to how to proceed, please help.

EDIT: Problem solved! Whereas WinRAR and PowerArchiver failed hard, a free little open source program called 7-Zip was able to accomplish the extraction without a hitch.

  • How in the world did you create an archive having files with the same name? – user1686 Dec 28 '13 at 9:48
  • 1
    One obvious possibility is that the archive was created on a Unix-like system, where filenames with differences in case are considered different, but Guest is trying to extract on a Windows system or a Mac where they are considered to be identical. – Jules Dec 28 '13 at 9:58
  • Simple: some of the files were added to the archive later, after it was already created. ZIP programs will let you do that. (I didn't do it, myself; some moron did. I am trying to recover his work.) – Guest Dec 28 '13 at 10:17
  • 2
    @Guest Have you tried 7-zip? It has an automatic rename feature during extracting when it detects duplicate filenames. I just tested it and it works perfect. Choose extract to directory and when it gives the screen to overwrite choose "Auto rename". Both versions are extracted correctly (with one named with _1 after it). Also 7zip does give you the opportunity to extract the correct file (the one you select) and not just the first/last version it encounters. – Rik Dec 28 '13 at 23:39
  • 1
    @Rik YES! IT WORKED! Problem solved. :D Thank you, so much. (A free program last updated in 2010? So much for owning the paid-for latest version of PowerArchiver. . . .) – Guest Dec 29 '13 at 0:03

You could try using infozip's unzip command line utility. It has an option -B to create a backup of any file overwritten during extraction, which might let you get two files out with the same name. You can download it from http://www.info-zip.org/.

If that doesn't work, it should be possible to write a program fairly easily using (for example) the Java java.util.zip.ZipInputStream class that steps through the file and extracts duplicate entries with new names. If you don't have the skill to do this yourself, there are various freelance hiring web sites with numerous programmers who could do it for not very much money.

| improve this answer | |
  • Thank you! I know someone who should be able to write such a program, so I have asked him if he will do so for me. I'll let you know if it works. – Guest Dec 28 '13 at 10:36
  • FYI, 7-Zip was able to accomplish it without a hitch. (Thanks again, Rik!) – Guest Dec 29 '13 at 0:05

You could try extracting the files one-by-one and then renaming after each extract. For that keep a DOS/CMD command ready (to rename newly created files) and a DOS/CMD window open to rename each new file possibly by appending a character at the end.

| improve this answer | |
  • As I mentioned, when I drag them out one at a time it only pulls the file that was most recently added to the archive (so even though I manually rename the files, they are duplicates anyway). I can see the different data in there, but I can't get to it either automatically or manually. – Guest Dec 28 '13 at 20:52

I’m still not sure how this situation even arises (where an archive can have multiple files with the same fully-qualified path and name)—it doesn’t make sense because the existing file should be updated/replaced instead of a new one being added.

Regardless, whenever I run into it, I simply get around it by using the auto-rename function that some archivers have. When you extract such an archive, the program will extract the first file with that name, then when it detects a collision on subsequent files, it will prompt you what you want to do. Most programs will offer the choice to ignore and move on or to overwrite, but some programs such as 7-Zip and WinRAR will let you rename the file and/or automatically rename all files with name collisions.

7-Zip (figure 1) will append an underscore with an incrementing number to the filename (e.g., foobar_1.txt, foobar_2.txt, etc.) while WinRAR (figure 2) will append a parenthesized incrementing number (e.g., foobar(1).txt, foobar(2).txt, etc.)

Figure 1 7-Zip’s filename-collision prompt

7-Zip’s filename-collision prompt with auto-rename option highlighted

Figure 2 WinRAR’s filename-collision prompt

WinRAR’s filename-collision prompt with rename options highlighted

Figure 3 Resulting filenames

Screenshot of Explorer with renamed files

| improve this answer | |
  • Doh! I guess I shouldn’t have stopped typing the answer for a couple of hours to have dinner and watch TV; it seems the answer I was typing has already been addressed in that time. Regardless, I’d already made screenshots, so I didn’t want them to go to waste. :^Þ – Synetech Dec 29 '13 at 1:37
  • Thanks for the informative reply! You summed up the whole issue quite nicely, problem fix and all. FYI though, WinRAR was the first program I tried, and I selected that option, but it didn't work! 7-Zip worked like a charm, but it's the only program I tried that worked. shrug (Edit: In their defense, it may be because I have an old version.) – Guest Dec 29 '13 at 5:33
  • WinRAR was the first program I tried, and I selected that option, but it didn't work Curious; that function has been present for a long time. Which rename button did you use? – Synetech Dec 29 '13 at 13:29
  • @Guest You might want to accept this answer as it does answer your question (and we wouldn't want to leave the question "open"). – Rik Dec 30 '13 at 23:14
  • (For the record, it has always annoyed me that 7Zip does not have a Rename option, only a Rename All option. I’ve been frustrated by that limitation on numerous occasions. ಠ_ಠ) – Synetech Dec 31 '13 at 1:39

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.