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

Posted on

QUESTION :

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?

ANSWER :

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.

Leave a Reply

Your email address will not be published.