<?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[Replace string across multiple files and increment value]]></title><description><![CDATA[<p dir="auto">I’m looking for an urgent solution! We need to append a text string in 1800+ XML files and increment the value by 1. Alternatively, I could append the text string with the filename of the doc. Either solution would work.</p>
<p dir="auto">Example 1<br />
Original string is Benjamin_poster.jpg across all files<br />
New value would be Benjamin_poster1.jpg, Benjamin_poster2.jpg etc.</p>
<p dir="auto">OR</p>
<p dir="auto">Example 2<br />
Original string is Benjamin_poster.jpg across all files<br />
New value would be Benjamin_poster[filename1].jpg, Benjamin_poster[filename2].jpg etc.</p>
<p dir="auto">Any help would be great.<br />
Thank you!</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/12967/replace-string-across-multiple-files-and-increment-value</link><generator>RSS for Node</generator><lastBuildDate>Sun, 09 Aug 2026 19:52:38 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/12967.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 23 Dec 2016 17:24:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Replace string across multiple files and increment value on Fri, 23 Dec 2016 19:49:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/scott-sumner" aria-label="Profile: Scott-Sumner">@<bdi>Scott-Sumner</bdi></a></p>
<p dir="auto">no pressure, no pressure - I thought of a simple solution like</p>
<pre><code>import os
search_string = 'HERE_YOUR_STRING'
i = 0
for root, dirs, files in os.walk('C:\\WHAT_EVER_DIR\\'):  # take care of double backslash like c:\\temp\\dir1\\
    for file in files:
        fname, ext = os.path.splitext(file)
        if ext == '.xml':
            i+=1
            full_path = os.path.join(root, file)
            with open(full_path) as f:
                s = f.read()
            s = s.replace(search_string, search_string + str(i))
            with open(full_path, "w") as f:
                f.write(s)
</code></pre>
<p dir="auto">but now, maybe an windows api solution?? ;-))</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/20250</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/20250</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Fri, 23 Dec 2016 19:49:20 GMT</pubDate></item><item><title><![CDATA[Reply to Replace string across multiple files and increment value on Fri, 23 Dec 2016 19:33:37 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/philip-lengden" aria-label="Profile: Philip-Lengden">@<bdi>Philip-Lengden</bdi></a></p>
<p dir="auto">I have no doubt that with <a class="plugin-mentions-user plugin-mentions-a" href="/user/claudia-frank" aria-label="Profile: Claudia-Frank">@<bdi>Claudia-Frank</bdi></a> on it, you will get more than a $20 solution.  :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/20249</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/20249</guid><dc:creator><![CDATA[Scott Sumner]]></dc:creator><pubDate>Fri, 23 Dec 2016 19:33:37 GMT</pubDate></item><item><title><![CDATA[Reply to Replace string across multiple files and increment value on Fri, 23 Dec 2016 19:21:37 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/philip-lengden" aria-label="Profile: Philip-Lengden">@<bdi>Philip-Lengden</bdi></a></p>
<p dir="auto">Few questions:<br />
Is there only one occurrence of the search string in each file or could it be multiple?<br />
If there are multiple search strings in one file should all be replaced with same value<br />
or should it be already incremented?<br />
If only each file should get the incremented value, what if a file doesn’t have the search string,<br />
can this incremented value be discarded or is it needed to assign it to the next file. Something like</p>
<p dir="auto">file1 has the search string and will be replace with new_value1<br />
file2 has the search string and will be replace with new_value2<br />
file3 has not the search string<br />
file4 has the search string and will be replaced with value (3 or 4)?</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/20248</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/20248</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Fri, 23 Dec 2016 19:21:37 GMT</pubDate></item><item><title><![CDATA[Reply to Replace string across multiple files and increment value on Fri, 23 Dec 2016 18:30:31 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <strong>Philip Lengden</strong>,</p>
<p dir="auto">Oh, many thanks for your <strong>offer</strong>, but I could had help you, for <strong>free</strong> , just for the <strong>pleasure</strong> to give you a <strong>decent</strong> solution ;-))</p>
<p dir="auto">Unfortunately, this kind of <strong>search / replacement</strong> can’t be easily achieved, even with the <strong>powerful regular</strong> expression engine,included in N++, because it needs some <strong>calculus</strong>, based on the <strong><code>+</code></strong> operation !</p>
<p dir="auto">But, don’t be sad ! This task should be easily run, in <strong>few</strong> lines of code, with a <strong>Python</strong> or <strong>Lua</strong> script, which can be performed, from inside Notepad++ ! However, up to now, I’m, <strong>personally</strong>, still <strong>unable</strong> to create such <strong>scripts</strong> !</p>
<p dir="auto">So, <strong>Claudia</strong>, <strong>Scott</strong> and <strong>dail</strong>, here’s the solution to improve your <strong>Christmas</strong>’s holidays ! Some more <strong>beer</strong> ? An other <strong>gift</strong> ?.. I’m joking, of course :-))</p>
<p dir="auto"><strong>Philip</strong>, I do hope that someone will <strong>help</strong> you, very soon !</p>
<p dir="auto">Best regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/20247</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/20247</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Fri, 23 Dec 2016 18:30:31 GMT</pubDate></item><item><title><![CDATA[Reply to Replace string across multiple files and increment value on Fri, 23 Dec 2016 17:47:36 GMT]]></title><description><![CDATA[<p dir="auto">$20 to the first correct submission ; )</p>
]]></description><link>https://community.notepad-plus-plus.org/post/20244</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/20244</guid><dc:creator><![CDATA[Philip Lengden]]></dc:creator><pubDate>Fri, 23 Dec 2016 17:47:36 GMT</pubDate></item></channel></rss>