Guido van Rossum | dc0493a | 1994-05-06 14:16:55 +0000 | [diff] [blame^] | 1 | #! /usr/local/bin/python |
| 2 | |
| 3 | import sys |
| 4 | import os |
| 5 | import string |
| 6 | |
| 7 | def main(): |
| 8 | args = sys.argv[1:] |
| 9 | if not args: |
| 10 | print 'no files' |
| 11 | sys.exit(1) |
| 12 | for file in args: |
| 13 | print file, '...' |
| 14 | data = open(file, 'r').read() |
| 15 | lines = string.splitfields(data, '\r') |
| 16 | newdata = string.joinfields(lines, '\n') |
| 17 | if newdata != data: |
| 18 | print 'rewriting...' |
| 19 | os.rename(file, file + '~') |
| 20 | open(file, 'w').write(newdata) |
| 21 | print 'done.' |
| 22 | else: |
| 23 | print 'no change.' |
| 24 | |
| 25 | main() |