<?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[Automatically selecting files with searched word in it]]></title><description><![CDATA[<p dir="auto">Hi guys, I’m fairly new with this program and I’ve got a question.<br />
I searched for a word in a directory, and it found occurrences in 220 files. Is there a way to automatically select and copy/paste those files in another directory?<br />
Thanks a lot!</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/18059/automatically-selecting-files-with-searched-word-in-it</link><generator>RSS for Node</generator><lastBuildDate>Wed, 13 May 2026 22:25:05 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/18059.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 07 Aug 2019 12:27:21 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Automatically selecting files with searched word in it on Thu, 08 Aug 2019 18:28:08 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/lorenzo-carrisi" aria-label="Profile: Lorenzo-Carrisi">@<bdi>Lorenzo-Carrisi</bdi></a></p>
<p dir="auto">Good that you got something you could use from that!</p>
<p dir="auto">Actually, this is probably a good opportunity to show off macros in Notepad++.</p>
<p dir="auto">First, do some (one-time) setup:</p>
<ul>
<li>Press the toolbar button for starting macro recording</li>
<li>In an editing tab view, press an arrow key to move the caret (this is just a dummy action)</li>
<li>Press the toolbar button for stopping macro recording</li>
<li>Press the toolbar button for saving a recorded macro; give it the name <code>Bat file from Find results</code> and save it</li>
<li>Exit Notepad++</li>
<li>Restart Notepad++</li>
<li>Locate your <code>shortcuts.xml</code> file and open it in Notepad++</li>
<li>Do a find on <code>Bat file from Find results</code> and you should be left looking at something like this:</li>
</ul>
<pre><code>&lt;Macro name="Bat file from Find results" Ctrl="no" Alt="no" Shift="no" Key="0"&gt;
    &lt;Action type="0" message="2306" wParam="0" lParam="0" sParam="" /&gt;
&lt;/Macro&gt;
</code></pre>
<ul>
<li><strong>Replace</strong> the <code>Action</code> line with the following block, making the indent level of the block match that of the old <code>Action</code> line:</li>
</ul>
<pre><code>&lt;Action type="3" message="1700" wParam="0" lParam="0" sParam="" /&gt;
&lt;Action type="3" message="1601" wParam="0" lParam="0" sParam="(?-s)^Search.+\R" /&gt;
&lt;Action type="3" message="1625" wParam="0" lParam="2" sParam="" /&gt;
&lt;Action type="3" message="1602" wParam="0" lParam="0" sParam="" /&gt;
&lt;Action type="3" message="1702" wParam="0" lParam="770" sParam="" /&gt;
&lt;Action type="3" message="1701" wParam="0" lParam="1609" sParam="" /&gt;
&lt;Action type="3" message="1700" wParam="0" lParam="0" sParam="" /&gt;
&lt;Action type="3" message="1601" wParam="0" lParam="0" sParam="(?-s)^\tLine.+\R" /&gt;
&lt;Action type="3" message="1625" wParam="0" lParam="2" sParam="" /&gt;
&lt;Action type="3" message="1602" wParam="0" lParam="0" sParam="" /&gt;
&lt;Action type="3" message="1702" wParam="0" lParam="770" sParam="" /&gt;
&lt;Action type="3" message="1701" wParam="0" lParam="1609" sParam="" /&gt;
&lt;Action type="3" message="1700" wParam="0" lParam="0" sParam="" /&gt;
&lt;Action type="3" message="1601" wParam="0" lParam="0" sParam="\s\(\d+\shits?\)$" /&gt;
&lt;Action type="3" message="1625" wParam="0" lParam="2" sParam="" /&gt;
&lt;Action type="3" message="1602" wParam="0" lParam="0" sParam='&amp;quot; .' /&gt;
&lt;Action type="3" message="1702" wParam="0" lParam="770" sParam="" /&gt;
&lt;Action type="3" message="1701" wParam="0" lParam="1609" sParam="" /&gt;
&lt;Action type="3" message="1700" wParam="0" lParam="0" sParam="" /&gt;
&lt;Action type="3" message="1601" wParam="0" lParam="0" sParam="^\s+" /&gt;
&lt;Action type="3" message="1625" wParam="0" lParam="2" sParam="" /&gt;
&lt;Action type="3" message="1602" wParam="0" lParam="0" sParam='copy &amp;quot;' /&gt;
&lt;Action type="3" message="1702" wParam="0" lParam="770" sParam="" /&gt;
&lt;Action type="3" message="1701" wParam="0" lParam="1609" sParam="" /&gt;
</code></pre>
<ul>
<li>Save the <code>shortcuts.xml</code> file</li>
<li>Exit Notepad++</li>
<li>Restart Notepad++</li>
</ul>
<p dir="auto">That’s the end of the one-time setup.  That will remain until you delete the macro created.</p>
<p dir="auto">To use it, each time you need to:</p>
<ul>
<li>Run a Find-in-Files search that results in several hit files</li>
<li>Copy and paste the Find-result panel results (per the earlier instructions on how to do that) into an empty Notepad++ tab (an empty file called <code>test.bat</code> might be appropriate!)</li>
<li>Go to the Macro menu and choose <code>Bat file from Find results</code> from near the bottom; you should observe your file of search results has changed into a bunch of <code>copy</code> batch file commands (this step “runs” the macro consisting of several replacement operations!)</li>
<li>Save the file</li>
<li>Continue from the earlier instructions at step <code>get a cmd prompt in the directory containing...</code></li>
</ul>
]]></description><link>https://community.notepad-plus-plus.org/post/46054</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/46054</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 08 Aug 2019 18:28:08 GMT</pubDate></item><item><title><![CDATA[Reply to Automatically selecting files with searched word in it on Thu, 08 Aug 2019 11:01:16 GMT]]></title><description><![CDATA[<p dir="auto">I didn’t quite manage to get the last part right, anyway just simply having the paths displayed like that helped me save quite a bit of time.<br />
Thanks a lot!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/46024</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/46024</guid><dc:creator><![CDATA[Lorenzo Carrisi]]></dc:creator><pubDate>Thu, 08 Aug 2019 11:01:16 GMT</pubDate></item><item><title><![CDATA[Reply to Automatically selecting files with searched word in it on Wed, 07 Aug 2019 12:58:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/lorenzo-carrisi" aria-label="Profile: Lorenzo-Carrisi">@<bdi>Lorenzo-Carrisi</bdi></a></p>
<p dir="auto">Automatically?  No.</p>
<p dir="auto">But with a “few” steps, not so hard:</p>
<ul>
<li>right-click in the Find result panel whitespace (anywhere)</li>
<li>choose Select All from the popup menu</li>
<li>press ctrl+c to copy</li>
<li>create a new file called <code>test.bat</code> in your desired destination directory</li>
<li>open <code>test.bat</code> in Notepad++</li>
<li>press ctrl+v to paste into N++'s buffer for <code>test.bat</code></li>
<li>choose Edit (menu) &gt; Line Operations &gt; …and pick the topmost sort option</li>
</ul>
<p dir="auto">Your file buffer should now have a group of lines at the top that start out with <code>Line</code> and a group of lines at the bottom that start with <code>Search</code>.  You want the grouping of lines in the middle, the ones that start out with actual pathnames and end with <code> (# hits)</code></p>
<ul>
<li>manually remove the <code>Line</code> lines at the top of the file</li>
<li>manually remove the <code>Search</code> lines at the bottom of the file</li>
<li>run this regular-expression replace on the whole file: Find: <code>(?-i)\s\(\d+\shits?\)(?=\R)</code> Repl: <code>" .</code></li>
<li>run this regular-expression replace on the whole file: Find: <code>^\s+</code> Repl: <code>copy "</code></li>
<li>press ctrl+s to save <code>test.bat</code></li>
<li>get a cmd prompt in the directory containing <code>test.bat</code></li>
<li>type <code>test</code> at the prompt and press Enter</li>
<li><strong>WATCH THE CMD OUTPUT AS ALL OF YOUR FILES ARE COPIED INTO THAT SINGLE DIRECTORY!</strong></li>
<li>delete the <code>test.bat</code> file</li>
</ul>
<p dir="auto">Note that this won’t work so well if any files have the same name (just the name.ext part) which can happen.  Be careful.</p>
<p dir="auto">Wow. I usually don’t give explanations like that.  I think I am channeling <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> while he is off fishing.  :)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/45997</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/45997</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 07 Aug 2019 12:58:32 GMT</pubDate></item></channel></rss>