#!/usr/bin/env python import sys, os from romaji import roma def main(): """Rename files in the path given in the first argument to a 'lossy' romaji version of their original name""" if len(sys.argv) < 2: print "Usage: python filename-to-romaji.py dir_with_files_to_convert" sys.exit(-1) path = sys.argv[1] for file in os.listdir(path): print 'Renaming ' + file + ' to ' + roma(unicode(file, 'utf-8')).encode('ascii', 'ignore') os.rename(path + file, path + roma(unicode(file, 'utf-8')).encode('ascii', 'ignore')) if __name__ == '__main__': main()