Skip to content

Instantly share code, notes, and snippets.

@mchome
Last active February 29, 2020 04:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mchome/aa356bda8df5b3a894961d63668a4b81 to your computer and use it in GitHub Desktop.
Save mchome/aa356bda8df5b3a894961d63668a4b81 to your computer and use it in GitHub Desktop.
日文文件名乱码修正
#!/usr/bin/python3
# -*- coding:utf8 -*-
import codecs
import os
def searchFolders(dir):
for root, dirs, files in os.walk(dir):
for file in files:
path = os.path.join(root, file)
if not path == os.path.join(os.getcwd(), 'normalize.py'):
os.renames(path, path.encode('gbk').decode('shift-jis'))
# print(path.encode('gbk').decode('shift-jis'))
# convertTexts(path)
# def convertTexts(file):
# with codecs.open(file,'r','shift-jis') as f:
# t = f.read()
# with codecs.open(file,'w','utf16') as a:
# a.write(t)
def main():
searchFolders(os.getcwd())
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment