Created
August 29, 2013 11:35
-
-
Save viyatb/6376967 to your computer and use it in GitHub Desktop.
Simple script to convert *nix text files to MS-DOS format.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def convert(format, fname): | |
for line in open(fname, 'rb').readlines(): | |
if format == 'todos': | |
if line[-1:]=='\n' and line[-2:-1] !='\r': | |
line=line[-1:]='\r\n' | |
elif format == 'tolinux': | |
if line[-2:]=='\r\n': | |
line=line[:-2] +'\n' | |
print " \n\nUnix to Dos and Dos To Linux file Convertor" | |
print " Usage : ./convertor.py <ToDos Or ToLinux > <filename> " | |
if len(sys.argv) == 3 : | |
convert ( sys.argv[1] , sys.argv[2] ) | |
print " Converted " , sys.argv[2] | |
else: | |
print " Usage : ./convertor.py <ToDos Or ToLinux > <filename> " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment