# Newline replacement



## pasc (Jun 21, 2014)

So let's assume that I have a text file with multiple newlines.

And I want to replace all those newlines that directly follow to each other with 'just one' newline.

How do I do this ?

Thanks in advance.



> Text
> 
> blabla
> 
> blublbublbublublb


----------



## foxidrive (Oct 20, 2012)

Test this with the sample data that you provided.

This uses a helper batch file called `repl.bat` (by dbenham) - download from: https://www.dropbox.com/s/qidqwztmetbvklt/repl.bat

Place `repl.bat` in the same folder as the batch file or in a folder that is on the path.


```
type file.txt |repl "^\r\n" "" xm|repl "\r\n" "\r\n\r\n" xm
```


----------



## Squashman (Apr 4, 2003)

Are you saying you want to remove all blank lines or do you want to keep one blank line between each line of text?


----------

