Last active
April 2, 2024 15:45
-
-
Save Limour-dev/ef201342dc16d05290143cd93e3d7b2f to your computer and use it in GitHub Desktop.
Notepad++ Batch Conversion Encoding
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
#-*- encoding:utf-8 -*- | |
# | |
# Notepad++ Python script plugin script. | |
# For converting file encoding & lineending. | |
# | |
import os | |
import sys | |
filePathSrc = notepad.prompt("请输入目录路径".decode('utf-8').encode('gbk'), "输入目录路径".decode('utf-8').encode('gbk')) | |
filter_exts = [".txt"] | |
for root, dirs, files in os.walk(filePathSrc): | |
for fn in files: | |
print fn.decode('gbk').encode('utf-8') | |
file_name, file_ext = os.path.splitext(fn) | |
if file_ext in filter_exts:# Specify type of the files | |
notepad.open((root + "\\" + fn).decode('gbk').encode('utf-8')) | |
print notepad.menuCommand(MENUCOMMAND.FORMAT_CONV2_AS_UTF_8) | |
notepad.save() | |
notepad.close() | |
print 'finish' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment