Skip to content

Instantly share code, notes, and snippets.

@Limour-dev
Last active April 2, 2024 15:45
Show Gist options
  • Save Limour-dev/ef201342dc16d05290143cd93e3d7b2f to your computer and use it in GitHub Desktop.
Save Limour-dev/ef201342dc16d05290143cd93e3d7b2f to your computer and use it in GitHub Desktop.
Notepad++ Batch Conversion Encoding
#-*- 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