3

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
  • 435
  • 2
  • 7
  • 17
  • most tools will happily accept multiple files as input, like `unix2dos *.txt` [Convert Unix line endings to Windows](https://superuser.com/q/71507/241386) – phuclv Oct 27 '18 at 03:35

1 Answers1

4

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
  • 81,981
  • 20
  • 135
  • 205