Introduction
When trying to zip multiple directories containing files with the same names using a batch file with 7zip, I encountered an unexpected 'Duplicate filename' error.
I searched the internet for a solution, but could not find an elegant solution.
<img src="1127369/Test7zip1.png" style="width: 640px; height: 289px;" />
Using the Code
The batch file, see below, should update an archive and when files with the same name are found, update it with the most recent file.
Although the syntax is correct, the first example with all directories on the same line will fail to update the files correctly:
del Test.zip
"C:\Program Files\7-Zip\7z.exe" u Test.zip C:\Temp\One\*.pdb C:\Temp\Two\*.pdb
The solution is simple, split up the command and use only one directory per line:
del Test.zip
"C:\Program Files\7-Zip\7z.exe" u Test.zip C:\Temp\One\*.pdb
"C:\Program Files\7-Zip\7z.exe" u Test.zip C:\Temp\Two\*.pdb
As can be seen in the output below at the bottom lines, one file is updated and one file is added:
<img src="1127369/Test7zip2.png" style="width: 640px; height: 581px;" />