This is a tool to enable textual search through directories of files compressed using the serz.exe compression algorithm, such as those used by RailWorks. The utility is used from the command line to locate files that contain specific strings and is perhaps most powerful when used in conjunction with find and xargs, thus:

find Networks/Track\ Tiles/ -type f -print0 |xargs -0 ~/serzgrep --verbose -n 00000000-0000-0000 --

which is a command I have used to locate orphaned track ribbons. Typical output from that command might be:

Decompress and Search Networks/Track Tiles/+000002-000007.bin
Networks/Track Tiles/+000002-000007~serz~.xml:1357:  <DevString d:type="cDeltaString">00000000-0000-0000-0000-000000000000</DevString>
Networks/Track Tiles/+000002-000007~serz~.xml:1366:  <DevString d:type="cDeltaString">00000000-0000-0000-0000-000000000000</DevString>
Networks/Track Tiles/+000002-000007~serz~.xml:1845:  <DevString d:type="cDeltaString">00000000-0000-0000-0000-000000000000</DevString>
Networks/Track Tiles/+000002-000007~serz~.xml:1854:  <DevString d:type="cDeltaString">00000000-0000-0000-0000-000000000000</DevString>
Decompress and Search Networks/Track Tiles/+000002-000008.bin
Decompress and Search Networks/Track Tiles/+000003+000006.bin

For the command line shown above, the "find" command first creates a list of filenames for the search to examine which are piped to "xargs", which then runs the given command with those files as command line arguments (but only as many as the system allows on one command). the -print0 and -0 options tell find and xargs to communicate using null-terminated strings, rather than newline-terminated strings, which makes the process more robust. 

In the example, the serzgrep program is located in the home directory of the user, which is referenced in bash using "~", and the options provided are "--verbose" which causes the names of files to be printed as they are examined, and -n, which is passed to grep and causes grep to put the line number of found strings in the otput. The string "00000000-0000-0000" is what it is being told to look for and finally, the "--" is a delimiter that MUST appear before any files are included on the command line: in this case it appears at the end of the xargs string because xargs will append files from the piped "find" output.


The file is a bash shell script, and requires cygwin installed. You can put it wherevery you like, although it is suggested that you include it in a directory in your PATH environment or you will have to provide a full path every time you use it. You should also use "chmod +x serzgrep" on the file in its final resting place to mark it as executable, or bash will ignore it.

Within the file, the location of your RailWorks folder is hard coded to a location suitable for RailWorks in the default Steam location on a 64-bit Windows OS. if your RailWorks is in another location you may have to change this. It is only needed to find the serz.exe executable.

If the serz executable is not found in the nominated "Railworks" folder the following message is displayed and execution terminates:

Warning: serz.exe not found or not executable.


This program is PUBLIC DOMAIN software and provided with NO WARRANTY, not even the implied warranty of fitness for a particular purpose. It is solely up to you to determine whether it is fit for any purpose or not, and to bear the consequences of that decision.

It served the purpose I had in mind when I created it, and future versions, if any, may enhance that. Should you improve it (without removing existing capability) I would value receiving a copy of the improved version and am happy to credit your input to it. However, you are free to do as you like with it.


Option processing is somewhat basic because of the decision not to try to understand the "grep" options themselves but simply to pass them on. This led to the requirement for "--" to signify the end of serzgrep and grep options and search term and the start of files to search through. serzgrep does however explicitly disable the "-r" option which to GNU grep causes grep to recurse down a directory tree, which would cause false negatives for this application.

Sserzgrep has some distinct options:

--verbose: mentioned above, cause the file name of the next file to be printed, along with "Decompress and Search" for files recognised as being in serz.exe compression format (by examining the file extension) and just "Search" for files recognised to be in plain text. Note that serzgrep assumes that files with .bin, GeoPcDx and .TgPcDx extensions are compressed XML text files, and files with .txt and .xml are plain text (xml) files.

--deferclean, --deferdelete: synonyms, causes serzgrep to only clean up (delete) uncompressed files at the end of its run. Note that when using the "find"/"xargs" invocation, the end of a find command is not the same as the end of a serzgrep as xargs will typically invoke its command many times.

--dontclean, --dontdelete: synonyms, causes serzgrep to leave uncompressed files around without cleaning up. It forgets about them thereafter: it is up to you to delete them again when you are finished.

Temporary Files

Serzgrep uncompresses the compressed files to temporary text files. These files are stored alongside their originals, to make it clear where they came from, and to avoid any clashes with other files, the string "~serz~" is inserted before the final extension, which is always .xml (a requirement of serz.exe). So /my/file.bin will be expanded to /my/file~serz~.xml

Although serzgrep does clean up after itself, use of options, or interrupting it during a search can cause uncompressed files to be left in the filesystem. You should delete these as soon as you can to avoid confusion and possible issues with RailWorks searches.

Environment and Dependencies

Serzgrep is a bash shell script intended to be run under a recent (2012) version of the cygwin environment. It requires access to the serz.exe file, shipped with RailWorks, and uses the cygpath utility from the cygwin environment to convert to the Windows style pathnames that Serz requires. it also requires an executable called "grep" and although it is tested with the cygwin grep there is no significant dependency on that version.

Attachment Size
serzgrep. 2.83 KB
Public Domain