1

I have a text file which uses the File Separator and Record Separator Ascii control characters as a carriage return and colon respectively.

I would like to make a batch file to search and replace all instances of the ascii File Separator (1C) and replace it with a standard carriage return symbol (0D).

I have searched around and found scripts which are close to this (such as finding and replacing printable ascii characters), but nothing for finding and replacing ascii characters.

1 Answers1

1

A good option is any utility that supports regex search and replace. There are various free Windows ports of sed and awk that should work.

I have written REPL.BAT - a hybrid JScript/batch utility that performs a regex search and replace on stdin and writes the result to stdout. The utility is pure script that runs natively on any modern Windows machine from XP onward. Full documentation is embedded within the script.

Assuming REPL.BAT is in your current directory, or better yet, somewhere in your PATH, then the solution is very simple:

type yourFile.txt | repl \x1C \x0D x >yourFile.txt.new
move /y yourFile.txt.new yourFile.txt >nul
Community
  • 1
  • 1
dbenham
  • 127,446
  • 28
  • 251
  • 390