Guest User

Untitled

a guest
Dec 16th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. # This script renames all files under this script's folder
  3. # Ruofei Du
  4. # 12/13/2017
  5. import glob, os
  6.  
  7. prefix = 'bing_'
  8. dir_path = os.path.dirname(os.path.realpath(__file__))
  9. sub_dir_list = glob.glob(dir_path + '*')
  10. for dir_item in sub_dir_list:
  11. files = glob.glob(dir_item + '/*.*')
  12. i = 0
  13. for f in files:
  14. p = f.rfind('.')
  15. extension = f[p+1:]
  16. if extension == 'cmd' or extension == 'py' or p < 0:
  17. continue
  18. os.rename(f, os.path.join(prefix + str(i) + '.' + extension))
  19. i += 1
Add Comment
Please, Sign In to add comment