Notepad++: Create shorcut to Batch file and open file afterwards

Posted on

Problem :

I have a batchscript with the following contents:

python.exe c:/path/to/my/pythonscript/ %1

which I currently use to be able to drag-n-drop a file onto it. then makes a duplicate of the file and processes it with some algorithm. Afterwards, it returns the path to the processed file on the commandline.

Now, what I want to achieve in N++ is: I want an icon in N++ on the toolbar -> When clicking this icon, I want to call the batchscript passing the filename/filepath of the currently opened file to it (which will effectively call python.exe c:/path/to/my/pythonscript/ FILEPATH_OF_OPENED_FILE_IN_NPP) and after the script is done, I’d like to automatically open the processed duplicate in N++.

I want to do it without using any sort of plugin. Is that possible?

I know it would be easily possible using some Plugins, e.g. using NppPythonScript, writing a script which calls the batchfile (using os.system(“blaa.bat”)) and then opening the resulting file using‘…’).

Is there a way without a plugin? Or maybe by writing a minimal plugin myself in C++ (as I’m not allowed to install any plugin from “inofficial” sources).


Solution :

No, you’d have to write a plugin. All it needs is to add an icon to the toolbar which, when clicked, calls a function performing the tasks you want. You can actually write the plugin in several languages such as Python, C#, Ada, etc. Here’s some guides to writing a Notepad++ plugin:

Update: I couldn’t any examples of plugins in Python, however, it should be possible because they have demos of plugins written in odd languages such as Delphi and Ada. I pulled these links from the fourth link up above.

Leave a Reply

Your email address will not be published. Required fields are marked *