Skip to content

Instantly share code, notes, and snippets.

@joonahn
Last active October 8, 2019 05:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save joonahn/430e2b2fa558603f678137dc2b6f80d1 to your computer and use it in GitHub Desktop.
Save joonahn/430e2b2fa558603f678137dc2b6f80d1 to your computer and use it in GitHub Desktop.
mac에서 생성한 한글 파일명을 windows에서 읽을 때 깨진 파일을 복구해 주는 스크립트
import sys
from unicodedata import normalize
import glob
import os
def nfd2nfc(data):
return normalize('NFC', data)
if len(sys.argv) > 1:
dirname = sys.argv[1]
diritems = glob.glob(os.path.join(dirname, '*'))
new_diritems = list(map(lambda x: nfd2nfc(x), diritems))
for src, dst in zip(diritems, new_diritems):
os.rename(src, dst)
@joonahn
Copy link
Author

joonahn commented Apr 24, 2018

Usage

$ python repair_broken_mac_filename.py your/target/dir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment