Страница 1 из 1

Batch converter of new line characters from unix to dos?

Добавлено: 02 мар 2009, 09:49
Demurrage
I've got lots of files with the unix new line (CR) and need to convert them all to the dos new line (CR + LF).
Is there are batch utility to make it happen?
I know there are utilities to make such a conversion for an individual file e.g. dos2unix etc, but how about a batch utility?

Re: Batch converter of new line characters from unix to dos?

Добавлено: 02 мар 2009, 10:49
CaptainBlack
Demurrage писал(а):I've got lots of files with the unix new line (CR) and need to convert them all to the dos new line (CR + LF).
Is there are batch utility to make it happen?
I know there are utilities to make such a conversion for an individual file e.g. dos2unix etc, but how about a batch utility?
#!/bin/bash
for i in $( ls ); do
unix2dos $i
done

Под CMD/DOS напиши крохотный скрипт с командой FOR.

Re: Batch converter of new line characters from unix to dos?

Добавлено: 02 мар 2009, 14:56
sobomax
perl -pi -e 's|\n|\r\n|' /path/*.foo

-Maxim

Re: Batch converter of new line characters from unix to dos?

Добавлено: 06 мар 2009, 15:27
Demurrage
Thanks, but had to write a little java program, because forgot to mention that the file structure was quite complex and I needed to recursively process all the folder & subfolders and process only ASCII files i.e. exclude binary files, so the algorithm wasn't that straightforward.