Skip to content

Instantly share code, notes, and snippets.

@comfuture
Created April 19, 2011 06:25
Show Gist options
  • Save comfuture/926919 to your computer and use it in GitHub Desktop.
Save comfuture/926919 to your computer and use it in GitHub Desktop.
recover broken shiftjis filenames
#!/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