Skip to content

Instantly share code, notes, and snippets.

@erenkeskin
Last active August 28, 2019 14:43
Show Gist options
  • Save erenkeskin/1946fef3f167a7b4599886e6417f0d99 to your computer and use it in GitHub Desktop.
Save erenkeskin/1946fef3f167a7b4599886e6417f0d99 to your computer and use it in GitHub Desktop.
### Hasan Eren Keskin
### http://herenkeskin.com
### Change all pdf name with space replaced '-' and lowercase
import os
import glob
path = os.getcwd()
# if you want to change jpg or png or whatever you want, you should change only '/**/*.pdf' extension
files = [f for f in glob.glob(path + "/**/*.pdf", recursive = True)]
# For Turkish Character
translationTable = str.maketrans("ğĞıİöÖüÜşŞçÇ", "gGiIoOuUsScC")
for file in files:
os.rename(os.path.join(path, file), os.path.join(path, file.replace(' ', '-')).lower().translate(translationTable))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment