Created
April 19, 2011 06:25
-
-
Save comfuture/926919 to your computer and use it in GitHub Desktop.
recover broken shiftjis filenames
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import os | |
import glob | |
import re | |
def recover(s, e='sjis'): | |
return re.sub(r'\\(...)', lambda m: chr(int(m.group(1), 8)), s).decode(e) | |
def rename(f): | |
os.rename(f, recover(f)) | |
if __name__ == '__main__': | |
map(rename, glob.glob('*')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment