How to update zip file with updated version of file originally in the zip file
Thread poster: Samuel Murray
Samuel Murray
Samuel Murray  Identity Verified
Netherlands
Local time: 00:57
Member (2006)
English to Afrikaans
+ ...
May 21, 2019

Hello

[I'm asking pretty much the same question in the hope that someone knows the answer this time.]

Suppose I have a zip file named foo.bar, with a file inside it named file.txt. Now suppose I unzip that file so that it creates a subfolder named "foo" that contains the file "file.txt" in it. Then suppose I edit the file.txt file (make chan
... See more
Hello

[I'm asking pretty much the same question in the hope that someone knows the answer this time.]

Suppose I have a zip file named foo.bar, with a file inside it named file.txt. Now suppose I unzip that file so that it creates a subfolder named "foo" that contains the file "file.txt" in it. Then suppose I edit the file.txt file (make changes to it). Now I want to put that updated file back into the original zip file. And do this 1000 times for 1000 zip files.

Do you know of a program that can do that? If you know of a program with a commandline option to do that, can you please tell me what the command syntax would be?

The online guides for 7-zip suggest that this would work:
7z.exe u foo.bar foo\*.txt
...but that actually creates a folder inside the zip file called "foo", with the file "file.txt" inside that folder (leaving the original file.txt untouched).

Surely there must be a way to unzip a zip file, edit the unzipped file, and then zip it back up again, using commandline. But how?

Thanks
Samuel
Collapse


 
Samuel Murray
Samuel Murray  Identity Verified
Netherlands
Local time: 00:57
Member (2006)
English to Afrikaans
+ ...
TOPIC STARTER
Okay, got it May 22, 2019

Samuel Murray wrote:
The online guides for 7-zip suggest that this would work:
7z.exe u foo.bar foo\*.txt
...but that actually creates a folder inside the zip file called "foo", with the file "file.txt" inside that folder (leaving the original file.txt untouched).


Got it. 1. You have to specify the full path of the file you want to add to the zip file. 2. You have to use "add", not "update".

Incorrect:
"C:\Program Files\7-Zip\7z.exe" u foo.xlz foo\content.xlf
(even if the command is run from D:\omegatproject\target\)

Incorrect:
"C:\Program Files\7-Zip\7z.exe" u "D:\omegatproject\target\foo.xlz" foo\content.xlf
(even if the command is run from D:\omegatproject\target\)

Correct:
"C:\Program Files\7-Zip\7z.exe" a "D:\omegatproject\target\foo.xlz" "D:\omegatproject\target\content.xlf"


 
Rolf Keller
Rolf Keller
Germany
Local time: 00:57
English to German
Files are not zipped independently of each other May 22, 2019

When you replace a file in a .zip, the zip's internal dictionary is extended by entries for the new file. But of course it is impossible to remove dictionary entries which hold for the old file only. So, the compression will be made worse, as well as the unzip speed. Depending on your scenario this can be negligible or not.

The optimal solution is to re-zip all the files in one go. But of course this takes more time.


 
Samuel Murray
Samuel Murray  Identity Verified
Netherlands
Local time: 00:57
Member (2006)
English to Afrikaans
+ ...
TOPIC STARTER
@Rolf May 22, 2019

Rolf Keller wrote:
The optimal solution is to re-zip all the files in one go.


The files I work on are small enough for this not to be an issue. So, I don't mind deleting the original zip file and then creating a whole new zip file all over again. But: is there a commandline command that will do that (without having to specify the full path of the zip file and the full path of every individual file that is to be added to the zip file)?

If I delete the original foo.xlz file (since I won't be needing it after unzipping it) and I now have a folder named foo, with a file content.xlf inside it, and I want to end up with a zip file called "foo.xlz" with the file content.xlf directly inside it (not inside a subfolder named "foo"), from where would I run the command, and what would be command be?


 
Rolf Keller
Rolf Keller
Germany
Local time: 00:57
English to German
Here you are May 22, 2019

1 - Go to the folder where old.zip resides.

2 - Unzip old.zip:
"C:\Program Files\7-Zip\7z.exe" e -spf old.zip -o.\temp -r

3 - Now change the content of \temp at will.

4 - Create new.zip:
cd temp
"C:\Program Files\7-Zip\7z.exe" a -tzip -spf ..\new.zip -r
del *.*

Make 4 into a batch file for your convenience. And make sure not to erase old.zip mistakenly.


 


To report site rules violations or get help, contact a site moderator:


You can also contact site staff by submitting a support request »

How to update zip file with updated version of file originally in the zip file






Anycount & Translation Office 3000
Translation Office 3000

Translation Office 3000 is an advanced accounting tool for freelance translators and small agencies. TO3000 easily and seamlessly integrates with the business life of professional freelance translators.

More info »
Wordfast Pro
Translation Memory Software for Any Platform

Exclusive discount for ProZ.com users! Save over 13% when purchasing Wordfast Pro through ProZ.com. Wordfast is the world's #1 provider of platform-independent Translation Memory software. Consistently ranked the most user-friendly and highest value

Buy now! »