User to user discussion and support for UltraEdit, UEStudio, UltraCompare, and other IDM applications.

Find, replace, find in files, replace in files, regular expressions
4 posts Page 1 of 1
Using the Replace in Files feature, you can only find ASCII/ANSI/OEM/Unicode text and replace that text with whatever you choose for all of a file type within a directory.

I have many text file in a directory where I need to strip out nulls (00h).

Can this be done in UltraEdit?

Yes, this is possible with several methods. For your case I suggest to use a Perl regular expression Replace in Files to remove all null bytes from your text files. The Perl regular expression search string is \x00 and the replace string is simply an empty string. With the Perl regular expression engine any byte sequence can be searched and replaced using hexadecimal notation in any file - binary or text file.

Note: Null bytes are normal in UTF-16 encoded files. So if your text files are UTF-16 encoded files and the application which should read in those files is not Unicode aware, better open those files in UltraEdit and convert them either to UTF-8 or to ASCII/ANSI instead of deleting all null bytes from the UTF-16 encoded files.
Best regards from Austria
That is working, but, I am getting a lot of 'out of memory' errors. How can that be tamed?
I do not understand why you should get any "out of memory" error on running a Replace in Files.

For testing I copied directory %windir%\SoftwareDistribution to a temporary folder, started UltraEdit and executed a Perl regular expression Replace in Files with search string \x00+, an empty replace string, with in files/types *.*, with directory being the copied directory, with search subdirectories enabled, and with option List changed files not enabled. Of course I did not have any of the binary or text files opened in UltraEdit as this is not necessary for a Replace in Files. After a few seconds a message box was displayed with showing the text "24320025 items replaced in 17 files".

I copied the directory once more, changed search string to \x00 to really remove each null byte separately from each file and enabled option List changed files. After a few seconds the output window opened with information on how many replaces were done on which files and finally showing "33833176 items replaced in 17 files". (Yes, it makes sense to apply the multiplier + on removing null bytes from binary files.)

I used 32-bit UE v22.20.0.34. I did not see any out of memory error message as expected because a Replace in Files does not use much memory at all (no undo recording, no display updates during execution).

If you can reproduce the occurrence of any out of memory error message with 64-bit version of UltraEdit on running a Replace in Files on not opened files, I would suggest to report this as an issue by email to IDM support.

Don't use Find in Files command with a Perl regular expression search string to find binary data bytes. Although the find itself works, the display of found "strings" in output window or results window won't as Find in Files is designed for text searches and not for binary data searches.
Best regards from Austria
4 posts Page 1 of 1