Source

convert-nfd-unicode-filesystem-to-nfc-unicode / src / convertnfdunicodefilesystemtonfcunicode / __init__.py

Full commit
import os
import sys
import unicodedata

from docopt import docopt


def fix_unicode(path, verbose=True):
    for root, dirs, files in os.walk(unicode(path), topdown=False):
        for entry in files:
            nfc = unicodedata.normalize('NFC', entry)
            if entry != nfc:
                os.rename(
                    os.path.join(root, entry),
                    os.path.join(root, nfc))

                if verbose:
                    print os.path.join(root, nfc)

        rootparent, rootentry = os.path.split(root)
        nfc = unicodedata.normalize('NFC', rootentry)
        if rootentry != nfc:
            os.rename(root, os.path.join(rootparent, nfc))
            if verbose:
                print os.path.join(rootparent, nfc)


def main():
    arguments = docopt(
"""Usage:
  convert-nfd-unicode-filesystem-to-nfc-unicode <path>
  convert-nfd-unicode-filesystem-to-nfc-unicode -h | --help | --version

""",
        version='0.1.0'
    )
    path = arguments['<path>']
    if not os.path.exists(path):
        sys.exit('Error, folder not found %s' % path)

    fix_unicode(path)