Notepad++ 使用 Python 脚本批量转换文件格式

admin 2021年9月1日14:57:35评论33 views字数 1230阅读4分6秒阅读模式

首先,我们需要将Notepad++语言改为英文。
接下来,下载Python Script插件的压缩包(我选的是Full版本)。
最后,把压缩包解压到Notepad++的程序根目录
最终的文件树应该是这样:

Notepad++            (your main Notepad++ directory, probably under "C:Program Files")
 +
 |-- python26.dll     (this is important. This needs to go in the main program directory of Notepad++,     next to notepad++.exe)
 |                    (unless you have a Python installation already, in which case it's probably in     C:windows already)
 +-- plugins
           
           |-- PythonScript.dll
           |
           |-- PythonScript
           |   
           |   |-- lib
           |   |    
           |   |     |-- (*.py)   lots of *.py files and subdirectories
           |   |
           |   |-- scripts
           |             
           |             |-- (machine-level scripts)
           |
           |
           |-- doc
           |    
           |     |-- PythonScript
           |             
           |             |-- PythonScript.chm         (optional, if it's not there context-sensitive help will use the web)
           |
           |
           |
           |
           |
           |-- Config     (this config directory can also be in %APPDATA%Notepad++pluginsconfig)
                         |
                         -- PythonScript
                                         
                                         |-- scripts
                                                   
                                                   |-- (user level scripts go here)    

现在,打开Notepad++->Plugins->Python Script->Show Console
若是能成功弹出命令行窗口,那便是安装成功了。

接下来,让我们来编写脚本(这里只能使用Python2.7的语法)

#coding=utf-8
import os
import sys

os.chdir(r"D:test")
for path in os.listdir(r"D:test"):
        print(path)
        notepad.open(path)
        notepad.runMenuCommand("Encoding","Convert to UTF-8")
        notepad.save()
        notepad.close()

这代码也是非常简洁明了的,嗯,这样就可以批量将test下的所有文件转换为UTF-8格式了。

FROM :rickyhao.com | rickyhao.com

相关推荐: Windows系统提权

/01 权限提升概述一,提权概述权限提升(privilege escalation):攻击者通过安全漏洞把获取到的受限制的低权限用户突破限制,提权至高权 限的管理员用户,从而获得对整个系统得控制权。 Windows:user –> administrat…

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年9月1日14:57:35
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   Notepad++ 使用 Python 脚本批量转换文件格式http://cn-sec.com/archives/499706.html

发表评论

匿名网友 填写信息