3

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.

Guest
  • 31

3 Answers3

1

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.

Jules
  • 481
0

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.

0

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

Synetech
  • 69,547