diff options
author | Andreas Rumpf <andreas@andi> | 2008-06-22 16:14:11 +0200 |
---|---|---|
committer | Andreas Rumpf <andreas@andi> | 2008-06-22 16:14:11 +0200 |
commit | 405b86068e6a3d39970b9129ceec0a9108464b28 (patch) | |
tree | c0449946f54baae6ea88baf453157ddd7faa8f86 /dos2unix.py | |
download | Nim-405b86068e6a3d39970b9129ceec0a9108464b28.tar.gz |
Initial import
Diffstat (limited to 'dos2unix.py')
-rwxr-xr-x | dos2unix.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/dos2unix.py b/dos2unix.py new file mode 100755 index 000000000..ff7938f7e --- /dev/null +++ b/dos2unix.py @@ -0,0 +1,24 @@ +#! /usr/bin/env python +"Replace CRLF with LF in argument files. Print names of changed files." + +import sys, os, glob + +def main(): + for arg in sys.argv[1:]: + for filename in glob.glob(arg): + if os.path.isdir(filename): + print filename, "Directory!" + continue + data = open(filename, "rb").read() + if '\0' in data: + print filename, "Binary!" + continue + newdata = data.replace("\r\n", "\n") + if newdata != data: + print filename + f = open(filename, "wb") + f.write(newdata) + f.close() + +if __name__ == '__main__': + main() |