Convert UNIX formated text files to DOS formated?

walterbyrd walterbyrd at iname.com
Wed May 13 05:56:55 CEST 2009


Thanks for shell script code. That code may be just as efficient, or
even more efficient, than python. But, to me, python is far more
readable.

------------
i=$1
i1=${i%%.*}
echo $i1
cat $1 | sed s/^M// >$i1._cr
-----------=


------------
import os

for file in os.listdir('.'):
        infile = open(file,'r')
        outfile = open( 'new_' + file, 'w')
        for line in infile:
                line = line.rstrip() + '\r\n'
                outfile.write(line)
        infile.close()
        outfile.close()
------------




More information about the Python-list mailing list