Advertisement
zephyrtronium

Untitled

Nov 4th, 2011
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. from __future__ import unicode_literals, print_function
  4.  
  5. import os
  6. import sys
  7.  
  8. keep_same = [
  9.     # Add the file types here you don't want to change.
  10.     '.zip', '.tar',
  11. ]
  12.  
  13. if len(sys.argv) < 2:
  14.     print('provide path')
  15.  
  16. for d in sys.argv[1:]:
  17.     if os.path.isdir(d):
  18.         for root, dirs, files in os.walk(d):
  19.             for fn in files:
  20.                 if not any(fn.endswith(ext) for ext in keep_same):
  21.                     s = os.path.join(root, fn)
  22.                     os.rename(s, s + '.txt')
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement