Notepad++ does not search and replace inside archive files. Your archives were corrupted because you performed search and replace on your RAR files themselves, rather than on the files contained in them.
Suppose you wanted to convert all text files in your folder from Mac to Unix. To do that, you have to replace all CR (0x0D
) characters with LF (0x0A
). Let's also assume your folder contains the following file named "Apple.txt.gz":
1f 8b 08 08 9c c1 81 55 02 00 41 70 70 6c 65 2e
74 78 74 00 0b c9 c8 2c 56 28 2d 4e 4d 51 e0 2d
c9 57 48 4a 55 48 cc e3 75 2c 28 c8 49 55 88 8d
56 48 cb cc 49 d5 e3 05 2b 01 22 de e2 92 cc 9c
1c a0 02 05 0c 15 84 0d 01 00 d3 0c 65 8c 68 00
00 00
This is a valid gzip archive containing a small text file "Apple.txt" with Mac-style CR line breaks. Notice that it contains a 0d
in the penultimate line.
If you open it in Notepad++, it looks similar to this:
‹œÁU Apple.txt ÉÈ,V(-NMQà-ÉWHJUHÌãu,(ÈIUˆVHËÌIÕã+"Þâ’Ìœ „
ÓeŒh
Replacing the CR with an LF and saving will result in a corrupt file. Go ahead, try it.
To avoid this is the future, you should specify filters in the "Find in Files" dialog. E. g., if your folder contains .txt, .htm, .html, .rar and .avi files, and you want to modify only text files and HTML pages, you enter *.txt *.htm *.html
into the "Filters" field. If that is not practical for some reason, you need to move the files that shouldn't be changed out of the folder in which Find in Files starts.
If you want to modify files inside archives, you have to extract them first, and recompress them after modification.
Not sure if I'm following. What does "search and replace on RAR files themselves" mean? And why would anyone do that? – Knocks X – 2015-06-16T02:43:43.723
@Knocks X Edited the answer, does that clarify it for you? And as you found out, it's a mistake to do that. ;) – Wolfram Schmied – 2015-06-17T19:50:45.047
I understand what Notepad++ is doing. It's treating a binary as a text. I just don't think it should do that. That's a job for hex editors. – Knocks X – 2015-06-17T22:47:33.260
1
You need to be careful around the eggs with that hammer. After all, Notepad++ is a text editor, not a Swiss chainsaw. ;)
https://en.wikipedia.org/wiki/Law_of_the_instrument
Yes, I am fully aware. But it's Notepad++ that's trying to act like a hammer and treating everything like a nail, not me. – Knocks X – 2015-06-18T01:46:52.527
Um, Notepad++ is a hammer. :D Like any powerful tool, it can be dangerous in inexperienced hands. ;) – Wolfram Schmied – 2015-06-18T19:31:45.407
1You seem to be in a mood to argue. The issue here is whether most users expect the described "hammer" behavior from a notepad app, and if not, whether it should be curbed in line with expectations. I have actually started a separate discussion on the Notepad++ support site, and so far most users tend to agree that it shouldn't be a hammer and ruin binary files. – Knocks X – 2015-06-18T22:14:32.127
That's an interesting definition of "most". I think we'll have to agree to disagree here. Until we meet again. ;) – Wolfram Schmied – 2015-06-19T16:53:10.530