#-*- 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'