Created
December 10, 2020 14:20
-
-
Save granttremblay/6da9b1820b68dee1c13bcc9d2a222a2d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import shutil | |
import glob | |
filelist = glob.glob('*.png') | |
for image in filelist: | |
stringarray = image.split('_') | |
namearray = stringarray[-1].split('---')[-1].split('.')[0].split('-') | |
try: | |
newfilename = namearray[0].lower() + '_' + \ | |
namearray[1].lower() + '.png' | |
shutil.copyfile(image, 'renamed/' + newfilename) | |
print(f'{image} copied to renamed/{newfilename}') | |
except: | |
print(f'Error on {image}, namearray is {namearray}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment