Advertisement
redsees

Untitled

Oct 6th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. #!/usr/bin/env python2
  2. try:
  3.     import os,shutil
  4. except ImportError:
  5.     print "[!] One or more library is missing...\n\n"
  6.     exit(-1)
  7.  
  8. current_dir = '.'
  9.  
  10. for subdirs, dirs, files in os.walk(current_dir):
  11.     for item in files:
  12.         old_value = ''
  13.         new_value = ''
  14.        
  15.         shutil.copyfile(os.path.join(subdirs,item),os.path.join(subdirs,item)+'.backup')
  16.  
  17.         fp = open(item,'r')
  18.         file_contents = fp.read()
  19.         new_file_contents = file_contents.replace(old_value, new_value)
  20.         fp.write(new_file_contents)
  21.         fp.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement