Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import shutil
- import sys
- print('NOTE: Please make sure that you have both a .jpg and a .png of the SAME filename, in the SAME directory. This will NOT work otherwise. Thank you.')
- targetImage = input('Target image name: ')
- if not targetImage:
- sys.exit()
- numChangedFiles = 0
- for path, dirs, files in os.walk('.'):
- if 'phase_' in path:
- for f in files:
- file_name, file_extension = os.path.splitext(f)
- if file_extension == '.jpg' or file_extension == '.png':
- path_name = os.path.join(path, f)
- if not targetImage in path_name:
- os.remove(path_name)
- shutil.copyfile(targetImage + file_extension, path_name)
- print('Replaced %s' % path_name)
- numChangedFiles += 1
- print('Replaced %s files.' % numChangedFiles)
- print('Done.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement