Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

blankrem.py

By: a guest on Dec 27th, 2013  |  syntax: None  |  size: 0.52 KB  |  hits: 38  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. # to run: python <this file> <files to remove blanks from>
  2.  
  3. from sys import argv
  4. from os.path import isfile
  5. for arg in argv:
  6.     if isfile(arg):
  7.         with open(arg,"r") as _in:
  8.             text = _in.read()
  9.             while "\n\n" in text:
  10.                 text = text.replace("\n\n","\n")
  11.             extstart = arg.rfind('.')
  12.             newname = arg[:extstart]+"_noblanks"+arg[extstart:]
  13.             with open(newname,"w") as out:
  14.                 out.write(text)
  15.     else:
  16.         print "no such file "+arg