Check duplicate filenames before extracting a ZIP
Inspect repeated paths, understand filename cleanup, and recover distinct payloads from a controlled archive.
Two different photos can share a filename. Combining collections into one flat folder can hide that distinction. Before extracting an export, inspect its paths: the number of files left on disk can be smaller than the number of entries in a perfectly valid ZIP.
Our archive contains two different files at one path
We used archiver to make a local ZIP with a JPEG and two entries both named duplicate.txt. Python’s inventory found all three entries and its CRC test found no damaged entry. Reading each duplicate by its individual entry object returned:
- Entry 2:
duplicate.txt, 5 bytes, contentfirst. - Entry 3:
duplicate.txt, 6 bytes, contentsecond.
The two payloads have different SHA-256 hashes, recorded in the inspection results. Download the intentional duplicate-name example to inspect it. Do not extract it over an existing folder: extraction applications can prompt, overwrite, rename, or otherwise handle repeated paths differently.
Check your ZIP before extracting
- Use your archive application’s list view. Look for repeated full paths, not just repeated basenames in separate folders.
- If Python is installed, the command below prints every duplicated full path and how many times it appears. An empty result means no exact duplicate paths were found; it does not check case-insensitive filesystem collisions.
- If repeats exist, return to the source and export the affected collections separately, or enable collection folders where available. Keep different exports in distinct empty folders.
- For an archive you must recover, use a tool that can inspect individual entries and save them under unique names. Do not assume the extracted folder contains every original payload.
python -c "import collections,zipfile; z=zipfile.ZipFile('metadata-and-duplicates.zip'); print({p:n for p,n in collections.Counter(z.namelist()).items() if n>1})"Filename cleanup does not make names unique
In the separate local helper check, a/b became a_b, a name another item could already use. Trimming long-holiday-photo.jpeg to a 12-code-point limit produced long-ho.jpeg. The extension remained, but part of the identifying name disappeared. These measured helper outputs are in results.json.
Folder grouping reduces collisions between collections; it does not guarantee that every filename inside one collection is unique. Afteralbum’s cleanup and these local library examples should not be read as a promise of automatic duplicate resolution in every export. Check your actual archive and retain the source until all intended items are accounted for.
