Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import re
- #whatever filter you would like to apply
- os.system('find * -type f | egrep -v ".svn" | egrep "\.(js|mustache|css|html|txt|less|sass|as|cfml|mxml)$" > /tmp/sourcefiles.txt')
- with open('/tmp/sourcefiles.txt') as f:
- files = f.read().strip().split("\n")
- for file in files:
- print "Processing", file
- with open(file, 'r') as f: #read the file
- lines = f.read().split("\n")
- for i,line in enumerate(lines):
- if re.search("^\s+", line): #if white space is detected at start of line replace it
- lines[i] = line.replace(" ","\t")
- with open(file, 'w') as f:
- str = "\n".join(lines)
- f.write(str)
- #print str
Add Comment
Please, Sign In to add comment