<?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[Row swap for multiple files]]></title><description><![CDATA[<p dir="auto">Hi there.<br />
Ive got like 4k+ files where I need to swap some row, is there any way to do that? , or do I need to change all the files manualy<br />
Thank you verry much for your time .</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/13070/row-swap-for-multiple-files</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Apr 2026 15:52:32 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/13070.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 10 Jan 2017 11:44:36 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Row swap for multiple files on Fri, 27 Jan 2017 05:58:49 GMT]]></title><description><![CDATA[<p dir="auto">if you do not feel comfortable with regex, like me</p>
<p dir="auto">do search for &lt;~~~ in all your files<br />
this is a “flag sequence”, so make sure that it is not already there</p>
<p dir="auto">if not found then go on.</p>
<p dir="auto">Find what:  &lt;FIRSTNAME&gt;<br />
Repl with:   &lt;~~~LASTNAME&gt;<br />
Mode:    Normal or Extended</p>
<p dir="auto">Find what:  &lt;LASTNAME&gt;<br />
Repl with:   &lt;~~~FIRSTNAME&gt;</p>
<p dir="auto">Find what:  &lt;/FIRSTNAME&gt;<br />
Repl with:   &lt;~~~/LASTNAME&gt;</p>
<p dir="auto">Find what:  &lt;/LASTNAME&gt;<br />
Repl with:   &lt;~~~/FIRSTNAME&gt;</p>
<p dir="auto">Find what:  &lt;FIRSTNAME /&gt;<br />
Repl with:   &lt;~~~LASTNAME /&gt;</p>
<p dir="auto">Find what:  &lt;LASTNAME /&gt;<br />
Repl with:   &lt;~~~FIRSTNAME /&gt;</p>
<p dir="auto">now check for any missed ones</p>
<p dir="auto">Find what:  &lt;FIRSTNAME<br />
Find what:  &lt;LASTNAME</p>
<p dir="auto">now delete the ~~~</p>
<p dir="auto">Find what:  &lt;~~~<br />
Repl with:   &lt;</p>
<p dir="auto">you could reduce number of steps</p>
<p dir="auto">Find what:  FIRSTNAME&gt;<br />
Repl with:   LASTNAME~~~&gt;</p>
<p dir="auto">Find what:  LASTNAME&gt;<br />
Repl with:   FIRSTNAME~~~&gt;</p>
<p dir="auto">those two would cover &lt;LASTNAME&gt; and &lt;/LASTNAME&gt;</p>
<p dir="auto">anyway i hope that  it helps you or anyone else</p>
]]></description><link>https://community.notepad-plus-plus.org/post/21285</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/21285</guid><dc:creator><![CDATA[Js jS]]></dc:creator><pubDate>Fri, 27 Jan 2017 05:58:49 GMT</pubDate></item><item><title><![CDATA[Reply to Row swap for multiple files on Thu, 12 Jan 2017 12:32:01 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7359">@Sascheya-Dragon-Shikamaru</a></p>
<p dir="auto">I took a quick look at your data.  As it is XML, what about swapping the <strong>FIRSTNAME</strong> and <strong>LASTNAME</strong> tags and leaving the data in-place?  But I think changing the tags is easier, especially since I saw some places in your data where there was a (empty) &lt;LASTNAME /&gt; tag instead of a &lt;LASTNAME&gt;foobar&lt;/LASTNAME&gt; grouping.</p>
<p dir="auto">Anyway, you could swap all FIRSTNAME and LASTNAME in your files using this Replace in Files operation:</p>
<pre><code>Find what: (FIRSTNAME)|(LASTNAME)
Repl with: (?1LASTNAME)(?2FIRSTNAME)
Mode: Regular expression
</code></pre>
<p dir="auto">Again, make sure you have a backup of your data before you entrust it to the Replace in Files feature.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/20852</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/20852</guid><dc:creator><![CDATA[Scott Sumner]]></dc:creator><pubDate>Thu, 12 Jan 2017 12:32:01 GMT</pubDate></item><item><title><![CDATA[Reply to Row swap for multiple files on Wed, 11 Jan 2017 13:18:31 GMT]]></title><description><![CDATA[<p dir="auto">It isn’t immediately obvious to me why your original thought will not work for multiple owners, as long as you replace ALL occurrences at once.</p>
<p dir="auto">Still, with ~4K files to do this on, I would think some sort of command line-based tool would be preferable to using a GUI-based tool like NPP.  Something like the UNIX sed utility, for example, or some scripting language.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/20810</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/20810</guid><dc:creator><![CDATA[Jim Dailey]]></dc:creator><pubDate>Wed, 11 Jan 2017 13:18:31 GMT</pubDate></item><item><title><![CDATA[Reply to Row swap for multiple files on Wed, 11 Jan 2017 07:24:42 GMT]]></title><description><![CDATA[<p dir="auto">Hello,<br />
First of all , I wana thank all of your for the responses, Ive learned quite a few things.<br />
Second, you guys are right I should have add’ed some more details, sorry for the troble, reading this remembered me that Ive got another problem.</p>
<p dir="auto">Long story short , 1 file = 1 land parcel that can have from 1 to many owners,  &lt;Person&gt;<br />
some smart ass translated: first name = the family name and the second = your name that you get at your birth.<br />
And now I need to swap the  content of &lt;FIRSTNAME&gt; &lt;/FIRSTNAME&gt; and &lt;LASTNAME&gt; &lt;/LASTNAME&gt; .<br />
My original trought was , find and replace FIRSTNAME with SOMENAME , then replace LASTNAME with FIRSTNAME, and after that SOMENAME with LASTNAME. And after all that to swap the rows.<br />
But… now Ive remembered there are cases where there are more then one 1 owner, and thats not gona work.<br />
Here are some examples:<br />
-with 1 owner: <a href="https://github.com/uZuRu17/origina_cgxml/blob/master/example" rel="nofollow ugc">https://github.com/uZuRu17/origina_cgxml/blob/master/example</a><br />
-with 4 owners: <a href="https://github.com/uZuRu17/origina_cgxml/blob/master/example.gitignore" rel="nofollow ugc">https://github.com/uZuRu17/origina_cgxml/blob/master/example.gitignore</a></p>
]]></description><link>https://community.notepad-plus-plus.org/post/20794</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/20794</guid><dc:creator><![CDATA[Sascheya Dragon Shikamaru]]></dc:creator><pubDate>Wed, 11 Jan 2017 07:24:42 GMT</pubDate></item><item><title><![CDATA[Reply to Row swap for multiple files on Tue, 10 Jan 2017 21:37:34 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <strong>Scott</strong>,</p>
<p dir="auto">Do you know ? My <strong>test</strong> file contained <strong>12</strong> lines only ( just enough to see the swapping of lines <strong>3</strong> and <strong>9</strong> !! ) So, I did <strong>not</strong> notice the obvious <strong>side-effect</strong> :-(( Ahhhhhhhhh !</p>
<p dir="auto">Indeed, your solution is the <strong>only</strong> way to <strong>avoid further</strong> matches, in the <strong>same</strong> file :-)) So, I just confirm : a <strong>Regex’s Master</strong> !</p>
<p dir="auto">Of course, I could, still, use the <strong><code>\K</code></strong> syntax just to avoid your <strong>first</strong> group <strong>1</strong>. But it look <strong>less elegant</strong> than your regex !</p>
<p dir="auto">Cheers,</p>
<p dir="auto">guy038</p>
<p dir="auto">Of course, I’m about to <strong>update</strong> my previous post !</p>
]]></description><link>https://community.notepad-plus-plus.org/post/20766</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/20766</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Tue, 10 Jan 2017 21:37:34 GMT</pubDate></item><item><title><![CDATA[Reply to Row swap for multiple files on Tue, 10 Jan 2017 20:21:51 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a></p>
<p dir="auto">Not a master, certainly, but just dangerous enough with regex  to get done what I need to, and maybe take a try at the more interesting posts here (while you are sleeping in France – don’t worry, still plenty for you to tackle!).</p>
<p dir="auto">So I tried your new regex with “Replace in Files” and I found that it suffers from a problem that one of my first tries also had:  It swaps more than lines 3 and 9 – it also swaps lines 12 and 18, lines 21 and 27, lines 30 and 36, …, and so on.  That is the reason I used (.*) at the end of my search regex along with \5 at the end of the replace text – it prevents this extra swapping, since the “spec” (that maybe I inferred) was to only swap one pair of lines.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/20762</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/20762</guid><dc:creator><![CDATA[Scott Sumner]]></dc:creator><pubDate>Tue, 10 Jan 2017 20:21:51 GMT</pubDate></item><item><title><![CDATA[Reply to Row swap for multiple files on Tue, 10 Jan 2017 21:48:32 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <strong>Sascheya Dragon Shikamaru</strong> and <strong>Scott</strong>,</p>
<p dir="auto"><strong>Sascheya Dragon Shikamaru</strong>, just <strong>SKIP</strong> this post, as I was totally <strong>wrong</strong> about my proposed <strong>regex</strong>. It does <strong>NOT</strong> work at all ! Thanks to <strong>Scott</strong> to pointing out the problem !</p>
<p dir="auto">Waaaouu ! <strong>Scott</strong>, you become a regex <strong>master</strong> : <strong>non-capturing</strong> groups, the <strong>two</strong> modifiers <strong><code>(?s-)</code></strong> and <strong><code>(?s)</code></strong> and the <strong><code>\R</code></strong> syntax  for <strong>line-breaks</strong> ;-))</p>
<p dir="auto">Looking at your regex, I had an <strong>intuition</strong> , that I verified and it worked <strong>fine</strong> ! Indeed, we just need of the <strong>block</strong> of lines, <strong>beginning</strong> at line <strong><code>X</code></strong> and <strong>ending</strong> at line <strong><code>Y</code></strong>, included ! We don’t care about <strong>any</strong> text, which is located <strong>before</strong> and/or <strong>after</strong> that block !</p>
<p dir="auto">So I would use the <strong><code>\K</code></strong> syntax to “<strong>forget</strong>”  the first lines ( your group <strong>1</strong> ) and just <strong>NOT</strong> add the <strong>remainder</strong> of each file scanned ( your group <strong>5</strong> ) ! This should improve the <strong>execution</strong> of the regex !</p>
<p dir="auto">So the <strong>general</strong> regex, with the <strong>Regular expression</strong> mode enabled, could be shortened :</p>
<p dir="auto">SEARCH <strong><code>(?-s)(?:.*\R){X-1}\K(.*\R)((?:.*\R){Y-X-1})(.*\R)</code></strong> DONT’WORK : Refer to the <strong>correct Scott</strong>’s regex, above !</p>
<p dir="auto">REPLACE <strong><code>\3\2\1</code></strong></p>
<p dir="auto">Where <strong><code>X</code></strong> is the <strong>lower</strong> line number of the <strong>first</strong> line to <strong>swap</strong> and <strong><code>Y</code></strong> is the <strong>higher</strong> line number.of the <strong>second</strong> line to <strong>swap</strong></p>
<p dir="auto">And for swapping, as you said, line <strong>3</strong> and <strong>9</strong>, the <strong>appropriate</strong> regex would be :</p>
<p dir="auto">SEARCH <strong><code>(?-s)(?:.*\R){2}\K(.*\R)((?:.*\R){5})(.*\R)</code></strong> DONT’WORK : Refer to the <strong>correct Scott</strong>’s regex, above !</p>
<hr />
<p dir="auto">Like you, I think that <strong>Jim</strong>’s post is really sensible. So, <strong>Sascheya Dragon Shikamaru</strong>, try to <strong>provide</strong> some more <strong>information</strong> : it would just help us to avoid some <strong>dead-ends</strong> and improve the <strong>quality</strong> of our answers, to solve your problem !</p>
<p dir="auto">Cheers,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/20761</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/20761</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Tue, 10 Jan 2017 21:48:32 GMT</pubDate></item><item><title><![CDATA[Reply to Row swap for multiple files on Tue, 10 Jan 2017 15:16:44 GMT]]></title><description><![CDATA[<p dir="auto">Jim is right, of course.  Earlier I just answered the simplest case, where the rows to swap occur in the same places in each file.  This may very well NOT be the case.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/20749</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/20749</guid><dc:creator><![CDATA[Scott Sumner]]></dc:creator><pubDate>Tue, 10 Jan 2017 15:16:44 GMT</pubDate></item><item><title><![CDATA[Reply to Row swap for multiple files on Tue, 10 Jan 2017 15:07:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7359">@Sascheya-Dragon-Shikamaru</a><br />
Based on the number of files you say are involved, I’m going to go ahead and say that using NPP isn’t the best way to achieve your goal.</p>
<p dir="auto">We really need more information to help you unless you are happy with an answer like, “<em>No, you don’t have to change all the files manually.</em>”</p>
<p dir="auto"><strong>Please describe your needs in detail.</strong> How are the lines to be swapped identified? Are they always particular line numbers or does it depend on the text contained on the lines? Is there a single pair of lines in each file? Are there varied numbers of pairs of lines in the files?  We need to know that type of information.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/20748</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/20748</guid><dc:creator><![CDATA[Jim Dailey]]></dc:creator><pubDate>Tue, 10 Jan 2017 15:07:29 GMT</pubDate></item><item><title><![CDATA[Reply to Row swap for multiple files on Tue, 10 Jan 2017 14:56:54 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7359">@Sascheya-Dragon-Shikamaru</a></p>
<p dir="auto">Something like the following could work…I encourage you to make a backup of your 4000 files before trying it!</p>
<p dir="auto">Use the “Replace in Files” feature.</p>
<pre><code>Find what: (?-s)((?:.*\R){X-1})(.*\R)((?:.*\R){Y-X-1})(.*\R)(?s)(.*)
Replace with: \1\4\3\2\5
Search mode: Regular expression
</code></pre>
<p dir="auto">Where X is the lower line number of the lines to swap and Y is the higher line number.</p>
<p dir="auto">Here’s a concrete example for swapping lines 3 and 9:</p>
<pre><code>Find what: (?-s)((?:.*\R){2})(.*\R)((?:.*\R){5})(.*\R)(?s)(.*)
Replace with: \1\4\3\2\5
Search mode: Regular expression
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/20747</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/20747</guid><dc:creator><![CDATA[Scott Sumner]]></dc:creator><pubDate>Tue, 10 Jan 2017 14:56:54 GMT</pubDate></item></channel></rss>