Processing binary files.
I need to edit each new version I receive of an .EXE program, to replace "eml" (Unicode) with "mht". Maybe I am missing something, but I haven't been able to do this with fnr 1.7. (The program creates .eml files; I use a setup that doesn't recognise this Microsoft email extension, but can open them with the .mht extension, the structure is the same). [The file I am using is the PopTrayU binary, extracted from the PopTrayU 5.0 beta 12 distribution. I can provide details if relevant, though any binary with embedded Unicode will probably behave the same.]
I'm not sure whether to add this to the the existing topic "Feature request - option to ignore binary file detection". That ended with "v1.4 now allows this", so I think a new topic is called for.
i have been trying to use fnr with the --skipBinaryFileDetection switch to handle executable files, and failing miserably. The program finds matches to my 3-character Unicode string and replaces them if --alwaysUseEncoding is "utf-7" or "utf-8", but completely garbles the file (changes every byte, increases the size by a factor of 2 or 3). In GUI mode the --alwaysUseEncoding switch is ignored, so I can only work in command-line mode.
I have been trying commands such as
"R:\fnr.exe" --cl --dir "R:" --fileMask "PopTrayU.exe" --SkipBinaryFileDetection --alwaysUseEncoding "utf-8" --find "eml" --replace "mht"
I can obviously do this with a hex editor, but fnr would let me make a CMD file once and for all. Can fnr do this, if so how? Some related suggestions:
- It would be useful, whatever else is done, to enable fnr in GUI mode to find and report the location of, if not replace, strings in any file, including binaries.
- It would be useful to enable --alwaysUseEncoding in GUI mode in general, possibly by including it on the command-line used to invoke the program. It would only make sense to allow replacement if clean replacement is possible (without corrupting the whole file).
-
it would be useful to allow clean replacement of strings in binary files, perhaps with a check that the replacement string is of the same length (with user notification rather than block). Obviously, only the specified string should be changed (I say this because the present replace massively corrupts the whole file), with a replacement normally of the same length.
Editing binaries may of course cause problems, but is safe enough if tested on a backed-up file. An attempt to edit a binary so should be clearly signposted rather than blanket-banned.
Having said that, fnr is brilliant. I use it to edit VMWare virtual machine .vmx files, interchanging a 4-line block; constructing a command line by hand would have been a pain, fnr's Gen Replace Command Line is brilliant to create batch files. I swap the entire blocks:
[hash]Lose changes this session at shutdown:
scsi0:0.mode = "independent-nonpersistent"
snapshot.action = "autoRevert"
snapshot.disabled = "TRUE"
displayName = "XP (no save)"
[hash]Keep changes:
scsi0:0.mode = "persistent"
snapshot.action = "keep"
snapshot.disabled = "FALSE"
displayName = "XP (
SAVES)"