Macro that changes file encoding and then saves?



  • I’m hoping to record a macro that will ‘convert to UTF-8’ and then save the file to a specific file name. I tried to use the “Start Recording” feature for this, but those actions aren’t captured. Is it possible to manually write a macro to do all of that?



  • @Clay-Gibney

    It should be possible with one of the scripting plugins available, e.g. NppExec. This plugin (like others as well) allows to create a menu entry in the Macro menu which can be assigned to a keyboard shortcut.

    But you should elaborate more precisely what you meant with

    @Clay-Gibney said:

    a specific file name

    Automatically generated from the original file name, following a certain rule? Or provided by user by opening a file selector dialog?



  • Thank you. I have a daily task where I open a uniquely named CSV file, and I have to encode it to UTF-8 and then perform a Save-As to a specific file name so I can then upload it into another system. So I was hoping to turn a few of those steps into a macro/menu choice.



  • @Clay-Gibney

    I guess we won’t know if you can achieve this unless you give @dinkumoil 's suggestion a try and report back on how it goes…



  • The NppExec plugin did the trick! Just two simple lines were all I needed:
    npp_menucommand Encoding\Convert to UTF-8
    NPP_SAVEAS: c:\users\clay\downloads\people.csv


Log in to reply