run system commands on save if certain criteria are met
-
I was wondering, is it possible to get Notepad++ to run some system commands if the current file’s folder meets some criteria?
I use clasp for developing Google Apps Script code. When you have a local copy of a Google Apps Script project the folder will have a
.clasp.jsonfile in it.I want it so if when I save a file and the folder has this
.clasp.jsonfile then it should automatically run a system command:cmd /c "cd $(CURRENT_DIRECTORY) && clasp push".Is this possible? I saw NppEventExec but could not figure out how to get it to do what I am after.
-
@imthenachoman said:
I was wondering, is it possible to get Notepad++ to run some system commands if the current file’s folder meets some criteria?
you should use lua or python script plugin for get notification when file is being saved

-
I don’t know Lua but I know Python. So I could create a Python script to run a function on save that would check for the existence of a specific file in the directory and then run other system commands?
-
Yes, using the
Pythonscriptplugin for Notepad++ :# -*- coding: utf-8 -*- from Npp import editor, notepad, NOTIFICATION def callback_npp_FILESAVED(args): for (filename, bufferID, index, view) in notepad.getFiles(): if bufferID == args['bufferID']: # do your stuff with "filename" file here break notepad.callback(callback_npp_FILESAVED, [NOTIFICATION.FILESAVED]) -
Humm. Thank you! I will give it a try.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login