• Login
Community
  • Login

Can I create a macro that gives the desired file name when creating a new file?

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
5 Posts 4 Posters 490 Views
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.
  • A
    andrecool-68
    last edited by Oct 22, 2021, 4:39 AM

    Hello to all participants of the forum!
    For example, this macro creates a new OEM 866 encoded file for batch, but the file name will always be “new 1”. The file name “new.bat” is required to have a file extension.

            <Macro name="NEW.BAT" Ctrl="no" Alt="no" Shift="no" Key="0">
                <Action type="2" message="0" wParam="41001" lParam="0" sParam="" />
                <Action type="2" message="0" wParam="46022" lParam="0" sParam="" />
                <Action type="2" message="0" wParam="45058" lParam="0" sParam="" />
            </Macro>
    
    A 1 Reply Last reply Oct 22, 2021, 11:27 AM Reply Quote 0
    • T
      Terry R
      last edited by Oct 22, 2021, 5:36 AM

      @andrecool-68 said in Can I create a macro that gives the desired file name when creating a new file?:

      The file name “new.bat” is required to have a file extension.

      You may want to read from this thread in this forum. I had thought the same as you, however the macro failed as the files are ONLY resident within NPP, not real files.

      There was some talk later in that thread that it was possible to edit the macro to include the Save As step, although it is not recordable in the normal sense. I don’t think I followed through much on that so can’t confirm there is a path forward to achieve what you want.

      Another idea that might work is to have an empty “template” file with the extension, so a real file. Have the macro load that, then rename, or save a copy as, would that work???

      Good luck
      Terry

      PS if successful could you provide the info here as I think there will be many wanting to know how it might be achieved.

      1 Reply Last reply Reply Quote 1
      • A
        Alan Kilborn @andrecool-68
        last edited by Oct 22, 2021, 11:27 AM

        @andrecool-68 said in Can I create a macro that gives the desired file name when creating a new file?:

        but the file name will always be “new 1”.

        I don’t think that’s going to always be true. It would depend upon if you already had an existing new 1 file when this macro is run, then I don’t think what the macro will saw will be saved in new 1.

        For this kind of automation it is probably best to go with the scripting plugins (e.g. PythonScript) or presumably NppExec can also achieve it.

        A M 2 Replies Last reply Oct 24, 2021, 11:47 AM Reply Quote 1
        • A
          andrecool-68 @Alan Kilborn
          last edited by andrecool-68 Oct 24, 2021, 11:48 AM Oct 24, 2021, 11:47 AM

          @Alan-Kilborn For me Python, is a dark forest.

          1 Reply Last reply Reply Quote 1
          • M
            mark Loss @Alan Kilborn
            last edited by Mar 1, 2023, 2:59 PM

            @Alan-Kilborn said in Can I create a macro that gives the desired file name when creating a new file?:

            @andrecool-68 said in Can I create a macro that gives the desired file name when creating a new file?:

            but the file name will always be “new 1”.

            I don’t think that’s going to always be true. It would depend upon if you already had an existing new 1 file when this macro is run, then I don’t think what the macro will saw will be saved in new 1.
            For this kind of automation it is probably best to go with the scripting plugins (e.g. PythonScript) or presumably NppExec can also achieve it.

            thanks my issue has been fixed.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors