What is the easiest way to convert a bunch of text files from LF (Unix) to CRLF (Windows) in a single run?

0

There is a directory tree on a Windows7 machine containing a few hundred text files that I want to convert from LF to CRLF.

I already found a Win32 version of UNIX2DOS but that one accepts only one file at a time for input whereas I want to convert a whole set of directories and subdirectories recursively in a single run.

What is the easiest way to accomplish that task?

Saul

Posted 2014-08-04T18:38:22.380

Reputation: 395

Question was closed 2018-10-29T16:19:44.703

most tools will happily accept multiple files as input, like unix2dos *.txt Convert Unix line endings to Windows

– phuclv – 2018-10-27T03:35:06.823

Answers

2

for one directory, open a command-prompt window, cd to the desired folder and

for %f in (*.txt) do UNIX2DOS %f ...

or for all subdirectories use the /R option

for /R %f in (*.txt) do UNIX2DOS %f ...

It may be worth remembering that, unlike notepad, editors like wordpad and notepad++ are happy with LF as line endings.

If you are converting a bunch of text files, you might also consider converting to UTF-8 using something like recode or iconv.

RedGrittyBrick

Posted 2014-08-04T18:38:22.380

Reputation: 70 632