Change EOL on multiple files in one go

Notepad++Batch ProcessingEol

Notepad++ Problem Overview


Is there any way in Notepad++ (or even with another tool) to change the line ending automatically on multiple files in one go?

i.e. convert a mix of windows EOL (CRLF) and UNIX EOL (LF) files to be all Windows EOL (CRLF)

Notepad++ Solutions


Solution 1 - Notepad++

The Replace dialog can handle extended characters like EOL. Just change "Search Mode" to "Extended", and you can work with EOL (\r\n in Windows or \n in Unix), tabs (\t), etc.

You can also use the Find in Files tab of the dialog to do the replace across multiple files.

Screenshot

Solution 2 - Notepad++

I have Notepad++ 6.1.2.
In "Edit" menu you have "EOL conversion" that does exactly what you need.

Solution 3 - Notepad++

Use the 'Find In Files' feature (Ctrl + Shift + F). Change the search mode at the bottom left to 'Regular Expression'.

In the 'Find what' box, use this pattern:

(?<!\r)\n

Replace with:

\r\n

Choose your directory and specify any file type filters. Check 'In all sub-folders' if you want. Click 'Replace in Files'.

What this does is replace any newline characters (\n) that are not currently preceded by a carriage return (\r) with \r\n. So it won't match line endings that are already Windows style.

enter image description here

Solution 4 - Notepad++

Use replace all with regular expression

(\r?\n)|(\r\n?)

to

\r\n

This will match every possible line ending pattern (single \r, \n or \r\n) back to \r\n (Windows).

To operate on multiple files, either:

  • Use "Replace All in all opened document" in "Replace" tab. You will have to drag and drop all files into Notepad++ first. It's good that you will have control over which file to operate on but can be slow if there several hundreds or thousands files.
  • "Replace in files" in "Find in files" tab, by file filter of you choice, e.g., *.cpp *.cs under one specified directory.

Solution 5 - Notepad++

The only WORKING solution i found for multiple files/folders, after googling for 1 hour is this:

  • install PyCham trial mode,
  • open and select your Project Folder/Folders and follow the screenshot

enter image description here

Solution 6 - Notepad++

Found this solution via this discussion:

> You can also set the default EOL in notepad++ via "Settings" -> > "Preferences" -> "New Document/Default Directory" then select > "Unix/OSX" under the Format box.

Note: One can always use an out-of-band option using the command line:

unix2dos *.cmd
dos2unix *.sh

Solution 7 - Notepad++

To convert multiple files into one directory and recursively. Just install PythonScript on Notepad ++, then use the script below

https://gist.github.com/bjverde/583c2ee8b386994f3a1f8acdea3b7ed2

Solution 8 - Notepad++

This did the work for me

git config core.autocrlf false 
git rm --cached -r . 
git reset --hard

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionfduffView Question on Stackoverflow
Solution 1 - Notepad++McGarnagleView Answer on Stackoverflow
Solution 2 - Notepad++MarcoView Answer on Stackoverflow
Solution 3 - Notepad++SeanView Answer on Stackoverflow
Solution 4 - Notepad++WappenullView Answer on Stackoverflow
Solution 5 - Notepad++Cristian MuscaluView Answer on Stackoverflow
Solution 6 - Notepad++R2ADView Answer on Stackoverflow
Solution 7 - Notepad++BjverdeView Answer on Stackoverflow
Solution 8 - Notepad++Maneth PathiranaView Answer on Stackoverflow