Skip to content

Instantly share code, notes, and snippets.

@alik472
Created June 22, 2020 13:11
Show Gist options
  • Save alik472/a52160e9fb655f50a3449a2df618078b to your computer and use it in GitHub Desktop.
Save alik472/a52160e9fb655f50a3449a2df618078b to your computer and use it in GitHub Desktop.
import os
from PIL import Image
files = os.listdir('.')
for f in files:
first_name = (f[:6])
last_name = (f[-4:])
jpg_name = '.PNG'
full_name = first_name + last_name
try:
im = Image.open(full_name)
im.save(first_name.upper() + jpg_name.upper(), "PNG")
except:
print(full_name)
continue
@alik472
Copy link
Author

alik472 commented Jun 22, 2020

import os

files = os.listdir('.')
for f in files:
newname = f.upper()
if newname == f:
continue
if newname in files:
print( "error: %s already exists" % newname )
os.rename(f, newname)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment