Skip to content

Instantly share code, notes, and snippets.

@theeluwin
Created October 27, 2021 02:52
Show Gist options
  • Save theeluwin/0711ae2d3b44be03b4dfb1d2157b9a3e to your computer and use it in GitHub Desktop.
Save theeluwin/0711ae2d3b44be03b4dfb1d2157b9a3e to your computer and use it in GitHub Desktop.
import os
from unicodedata import normalize
def walk_normalize(target_dir):
for root, dirs, files in os.walk(target_dir):
for name in files:
path = os.path.join(root, name)
if name == '.DS_Store':
os.remove(path)
continue
os.rename(path, normalize('NFC', path))
for name in dirs:
path = os.path.join(root, name)
os.rename(path, normalize('NFC', path))
if __name__ == '__main__':
walk_normalize('temp')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment