批量转换编码是很痛苦的事情,一种办法是自己去写代码来实现,你得解析判断文件编码的类型utf-8 utf-16 ansi ucs-2,然后判断,难保证都成功的转换。提供一种利用第三方工具批量转换成utf-8 ansi等。
安装nodepad++及插件
Plugins->Plugin Manager->Show Plugin Manager
Python Script安装重启Notepad++
Plugins->Python Script->New script
输入名字toUtf-8,然后复制下面python脚本
运行脚本Plugins->Python Script->scripts->toUtf-8
python脚本
转换utf-8、注意备份,是直接把文件编码转换,不支持中文路径
import os;
import sys;
from Npp import notepad #这里必须导入nodepad++ if i note this line, it says, "notepad is not defined"
filePathSrc="E:\\Beyond2\\"#"E:\\Songs2\\" # Path to the folder with files to convert
for root, dirs, files in os.walk(filePathSrc):
for fn in files:
if fn[-4:] == '.dtx': # Specify type of the files 判断指定的后缀名
notepad.open(root + "\\" + fn)
notepad.runMenuCommand("Encoding", "Convert to UTF-8")#想转成ANSI 替换UTF-8
notepad.save()
notepad.close()