How to edit a file in a zip or rar archive?
Solution 1
7-Zip can do this:
- If not already done, would recommend setting the file editor to something better than the Windows standard Notepad, e.g. Notepad++. To do this in 7-Zip, go to Tools -> Options..., select the editor tab and change the "Editor" path (and may as well also change the "View" path) to the relevant executable, e.g.
"C:\Program Files (x86)\Notepad++\notepad++.exe" -multiInst
. The-multiInst
option opens this in a new window - see comment from Simo Kivistö. - Open the archive in 7-Zip.
- Locate the file to be edited.
- Right-click on the file to edit and select "Edit" (alternative shortcut = F4). Make your changes, save them and close the editor window - 7-Zip will only detect the file has changed when the editor has been closed.
- When 7-Zip detects the file has been changed it will display a prompt such as "File 'abc.txt' was modified. Do you want to update it in the archive?". Click on OK and it will then load the changed file back into the zip file, which may take a bit of time.
Solution 2
Simple answer is NO. There's no way to tell how big the resulting file will be after edit so it can't just be stored back in the same place in the zipfile. What you might be able to find is a program that allows you to do the extract/edit/rezip without you having to worry about the details yourself. It would help to specify your environment (OS etc).
Solution 3
At least on Linux and Windows+Cygwin, you can use vim
It will let you browse inside the ZIP file, choose a text file and press Enter ↵ to edit it
Solution 4
Use Total Commander. Navigate to the archive, hit Enter to enter the specific file you want to modify, hit Save after modify and close the editing program. Total Commander will ask you if you want to update the archive so you hit Yes.
Solution 5
Open the zip file with winrar, double click an embedded text file, it should open in an external editor. Change and close the text file. Winrar then asks if it should updated the archive with the changed file.
Related videos on Youtube
![Mankind1023](https://i.stack.imgur.com/g5Msx.jpg?s=256&g=1)
Mankind1023
Updated on September 17, 2022Comments
-
Mankind1023 almost 2 years
I have a large archive with files that I need to edit, but I don't want to extract / zip every time. Is there a way to edit the files directly while in the archive? I opened them and when I save it prompts for a location.
-
Mankind1023 over 13 yearsI'm using windows 7 and Winrar, for the moment I extracted / edited / re-archived the file which was a pain, but I will try one of these programs if the needs arise, which I'm sure it will, hopefully they work.
-
Tilo about 6 yearsgood info, if you get
***error*** (zip#Write) sorry, your system doesn't appear to have the zip pgm
load ZIP stackoverflow.com/a/31988175/1747983 -
Noumenon almost 6 years@JinSnow Thanks a lot. Similarly, when the editor is Word, you have to close every open Word window.
-
JinSnow almost 6 years1: In 7-zip option, you can set np++ as editor. 2: If you use np++ to edit 7zip, be careful: saving isn't enough, you have to close np++ (7zip doesn't detect the change unless you close np++)
-
Wossname over 5 yearsCan this work on binary files?
-
beppe9000 about 5 yearsdoesn't work for guzzle's phar
-
beppe9000 about 5 yearsdoesn't work for me, it triggers explorer's unknown file type dialog
-
Simo Kivistö over 3 yearsStep 1: write the notepad++ path as follows:
"C:\Program Files (x86)\Notepad++\notepad++.exe" -multiInst
. This way it opens the file in a new window and you only have to close that. Also: F4 is a handy shortcut for opening the file for editing. -
Steve Chambers about 3 years@SimoKivistö Thanks - have now incorporated these suggestions in the answer.
-
georgiecasey about 3 yearsThanks @JinSnow. Having to close notepad++ is a real gotcha. I'd say most people miss that 7zip can edit files in place because of that.