Skip to content

Instantly share code, notes, and snippets.

Created January 13, 2019 15:29
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
import os
from PIL import Image # pip install Pillow
import pytesseract # pip install pytesseract
newly_renamed = 0
not_renamed = 0
for subdir, dirs, files in os.walk('./memes'):
for file in files:
src_path = os.path.join(subdir, file)
tmp_path = os.path.join('./tmp/', file)
img ='L')
bw = img.point(lambda x: 0 if x < 249 else 250, '1')
img =
new_text = pytesseract.image_to_string(img).strip()
if new_text:
newly_renamed += 1
not_renamed += 1
new_text = src_path
print(f"{newly_renamed} files newly renamed vs. {not_renamed} still have the same old name.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment