Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- # This script renames all files under this script's folder
- # Ruofei Du
- # 12/13/2017
- import glob, os
- prefix = 'bing_'
- dir_path = os.path.dirname(os.path.realpath(__file__))
- sub_dir_list = glob.glob(dir_path + '*')
- for dir_item in sub_dir_list:
- files = glob.glob(dir_item + '/*.*')
- i = 0
- for f in files:
- p = f.rfind('.')
- extension = f[p+1:]
- if extension == 'cmd' or extension == 'py' or p < 0:
- continue
- os.rename(f, os.path.join(prefix + str(i) + '.' + extension))
- i += 1
Add Comment
Please, Sign In to add comment