Convert NewLine \n to \r\n in large text files

I’m currently doing a lot of coding on both Linux and Windows, and this small tool has been helpful to me. It’s not complicated, it just converts all \n line ending’s to \r\n in a textfile. It performs okay, even when the files get above 1 GB it performs within a few minutes.

Specifically, I couldn’t make bcp work with CSV files with \n endings (it seems that bcp automatically adds a \r when \n is specified as the row delimiter, thank you bcp…).

If you have the same need, feel free to download from http://www.box.net/shared/x0tfvdlgy5.

Usage:
n2rn /? to display usage
n2rn filename will convert a file and output it as filename.n2rn
nr2n filename -o outputfilename will convert a file and output it as outputfilename
n2rn filename -o outputfilename -w will convert a file, output it as outputfilename and overwrite any existing outputfilename.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s