Advertisement
loon4tic

hehe

Sep 27th, 2020 (edited)
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. import os
  2. import shutil
  3. import sys
  4.  
  5. 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.')
  6.  
  7. targetImage = input('Target image name: ')
  8. if not targetImage:
  9. sys.exit()
  10.  
  11. numChangedFiles = 0
  12.  
  13. for path, dirs, files in os.walk('.'):
  14. if 'phase_' in path:
  15. for f in files:
  16. file_name, file_extension = os.path.splitext(f)
  17. if file_extension == '.jpg' or file_extension == '.png':
  18. path_name = os.path.join(path, f)
  19. if not targetImage in path_name:
  20. os.remove(path_name)
  21. shutil.copyfile(targetImage + file_extension, path_name)
  22. print('Replaced %s' % path_name)
  23. numChangedFiles += 1
  24.  
  25. print('Replaced %s files.' % numChangedFiles)
  26. print('Done.')
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement