Community
    • Login

    run system commands on save if certain criteria are met

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    5 Posts 3 Posters 1.3k Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • imthenachomanI Offline
      imthenachoman
      last edited by

      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.json file in it.

      I want it so if when I save a file and the folder has this .clasp.json file 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.

      1 Reply Last reply Reply Quote 0
      • rinku singhR Offline
        rinku singh
        last edited by

        @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

        link text

        1 Reply Last reply Reply Quote 2
        • imthenachomanI Offline
          imthenachoman
          last edited by

          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?

          Alan KilbornA 1 Reply Last reply Reply Quote 1
          • Alan KilbornA Offline
            Alan Kilborn @imthenachoman
            last edited by

            @imthenachoman

            Yes, using the Pythonscript plugin 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])
            
            1 Reply Last reply Reply Quote 3
            • imthenachomanI Offline
              imthenachoman
              last edited by

              Humm. Thank you! I will give it a try.

              1 Reply Last reply Reply Quote 0

              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
              • First post
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors