Sideway BICK BlogSideway BICK BLOG from Sideway

A Sideway to Sideway Home

Link:http://output.to/sideway/default.asp?qno=160300005

Python Script for NotePad++ Examples

Python Script for Notepad++ Examples

Python Script for Notepad++ is a scripting plugin for Notepad++ to process some command automatically.

  1. Making use of the "convert to UTF-8' function of Notepad++ to convert the encoding of a text file from other encoding to UTF-8 encoding.

    Python Script:

    import os;

    import sys;

    path = 'D:\\tempfile\\'

    extensions = ['.htm', '.asp', '.html']

    # Function of using Notepad++ commands

    def processDirectory(args, dir, files):

     for file in files:

    for extension in extensions:

    if file[-len(extension):] == extension:

    notepad.open(dir + "\\" + file)

    notepad.runMenuCommand('Encoding', 'Convert to UTF-8')

    notepad.save()

    notepad.close()

    break

     # Run script and call function processDirectory() recursively

    os.path.walk(path, processDirectory, None)

    console.write( 'DONE!')

  2.  

Sideway BICK Blog

05/03


Copyright © 2000-2020 Sideway . All rights reserved Disclaimerslast modified on 26 January 2013