Last active
February 29, 2020 04:03
-
-
Save mchome/aa356bda8df5b3a894961d63668a4b81 to your computer and use it in GitHub Desktop.
日文文件名乱码修正
This file contains 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/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