Skip to content

Instantly share code, notes, and snippets.

@garsaud
Created June 28, 2017 20:41
Show Gist options
  • Save garsaud/0e0138ac47d2e7f212942d44c16b90f3 to your computer and use it in GitHub Desktop.
Save garsaud/0e0138ac47d2e7f212942d44c16b90f3 to your computer and use it in GitHub Desktop.
Rename files in current directory to lowercase. Also works on windows.
import os
"""
Make every filename within the same directory lowercase, adding a temporary
character in the process to fool windows into believing that the filename has
really changed (windows treats filenames as case insensitive)
Usage: python lowercase.py
"""
c = "-"
path = os.getcwd()
filenames = os.listdir(path)
for filename in filenames:
os.rename(filename, filename+c)
os.rename(filename+c, filename.lower())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment