Can I create a macro that gives the desired file name when creating a new file?
-
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>
-
@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
TerryPS if successful could you provide the info here as I think there will be many wanting to know how it might be achieved.
-
@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 innew 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.
-
@Alan-Kilborn For me Python, is a dark forest.
-
@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.