Created
July 10, 2015 14:36
-
-
Save ih4cku/eec4ff028e6e4e1b0bc7 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
import os | |
import sys | |
from os import path | |
script_dir = '/opt/rnnlib-utils' | |
scripts = os.walk(script_dir).next()[2] | |
for sc in scripts: | |
sc = path.join(script_dir, sc) | |
if sc.endswith('.sh'): | |
sb = '#! /bin/bash' | |
elif sc.endswith('.py'): | |
sb = '#!/usr/bin/env python' | |
else: | |
continue | |
print 'processing', sc | |
with open(sc) as f: | |
codes = f.readlines() | |
if codes[0].strip() != sb: | |
codes.insert(0, sb+'\n') | |
with open(sc, 'w') as f: | |
f.writelines(codes) | |
print 'done.' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment