Skip to content

Instantly share code, notes, and snippets.

@olivierlemoal
Last active February 20, 2016 13:11
Show Gist options
  • Save olivierlemoal/cd7a279e338773c2773b to your computer and use it in GitHub Desktop.
Save olivierlemoal/cd7a279e338773c2773b to your computer and use it in GitHub Desktop.
#! /usr/bin/env python3
import sys
import os
from path import path
if len(sys.argv) < 2:
print("Usage : {} path".format(sys.argv[0]))
exit(1)
path = path(sys.argv[1])
for file in path.walkfiles():
try:
fixed_name = file.encode("iso-8859-1").decode("utf-8")
except:
continue
if fixed_name != file:
os.rename(file, fixed_name)
print("{} renamed in {}".format(file, fixed_name))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment