<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[batch script run in place]]></title><description><![CDATA[<p dir="auto">I can run my script in place, but is there a way I can save the file when I (before) I run (ctrl+s)</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/26670/batch-script-run-in-place</link><generator>RSS for Node</generator><lastBuildDate>Wed, 10 Jun 2026 19:37:03 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/26670.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 04 Mar 2025 04:33:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to batch script run in place on Tue, 04 Mar 2025 20:11:17 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/chris-robertson" aria-label="Profile: Chris-Robertson">@<bdi>Chris-Robertson</bdi></a> ,</p>
<p dir="auto">You didn’t say, but for the sake of my answer, I will assume when you say “I can run my script in place”, you mean “I use the <strong>Run &gt; Run</strong> menu command to run <code>cmd /c "$(FILE_NAME)"</code> (or similar) to run the active file using its default assocation” or maybe “I have saved that <strong>Run &gt; Run</strong> command into the <strong>Run</strong> menu, and maybe have a keyboard shortcut for it”.  If I have misinterpreted your statement, you will have to clarify with much more detail.</p>
<p dir="auto">The Notepad++ <a href="https://npp-user-manual.org/docs/macros/" rel="nofollow ugc">macro system</a> can record certain actions then play them back.  Unfortunately, as explained in our <a href="/topic/25400">FAQ: Automating Notepad++</a>, certain commands – like those from plugins, and the user-defined commands that you save in the Run menu (or even calls to other macros) – cannot be <em>recorded</em> .  However, that same FAQ explains that you can <a href="/post/99440">trick the macro system</a> to run non-recordable commands by manually editing the macro, as described in that second post.  So you could manually create a macro that runs the <strong>File &gt; Save</strong> then runs the dynamic menuCmdID assigned to your Run command or Plugin command, that you can find using UISpy!</p>
<p dir="auto">Alternatively, the NppExec plugin is designed for being a “shell scripting” language for Notepad++, allowing running various N++ commands and various filesystem commands.  I have saved the following NppExec script as <code>RunMyself</code>, which saves the active file, changes to that file’s directory, and runs that file:</p>
<pre><code>NPP_SAVE
cd "$(CURRENT_DIRECTORY)"
cmd /c "$(FILE_NAME)"
</code></pre>
<p dir="auto">… and I use Shortcut Mapper to set its keyboard shortcut to <code>F5</code> (and relegate the <strong>Run&gt;Run</strong> command to <code>Ctrl+Shift+F5</code>, because I’d rather have the easiest shortcut be for the actions I use the most)</p>
<p dir="auto">You could do a similar script for the PythonScript plugin or other of the scripting plugins, but IMO, NppExec is best suited when you are trying to do just a sequence of actions that are too complex for Macros, but don’t have the logic or computational needs of a full programming language like Python.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/100187</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/100187</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Tue, 04 Mar 2025 20:11:17 GMT</pubDate></item></channel></rss>