How do i remove a duplicate line after a particular combination?
-
Let’s say i have this in my notepad:
<path>./gamename1567/gamename1567.cue</path> <image>C:/images/gamename1567/gamename1567.png</image>
And i want to do this:
<path>./gamename1567/gamename1567.cue</path> <image>C:/images/gamename1567.png</image>
You can see the “gamename” is mentioned twice in the <path> section and i need that as is. But i want the second “gamename” removed if it’s in the <image> section.
There are thousands of lines with different “gamenames” in that text file. So i can’t just replace
“gamename1567.png</image>”
with
“</image>”
Because that will affect only one game in the list. I’m stuck!
-
Hello, @tasos-akrido and All,
Very easy with regular expressions !
-
Open the Replace dialog (
Ctrl + H
) -
SEARCH
(?-s)^(\h*<image>C:/images)/.+(/.*\.png</image>)
-
REPLACE
\1\2
-
Tick, preferably, the
Wrap around
option -
Select the
Regular expression
search mode -
Click once on the
Replace All
button or several times on theReplace
button
Voila !
So, for instance, the text :
<path>./gamename1567/gamename1567.cue</path> <image>C:/images/gamename1567/gamename1567.png</image> <path>./gamename37/gamename37.cue</path> <image>C:/images/gamename37/gamename37.png</image> <path>./gamename12345/gamename12345.cue</path> <image>C:/images/gamename12345/gamename12345.png</image>
would be changed into :
<path>./gamename1567/gamename1567.cue</path> <image>C:/images/gamename1567.png</image> <path>./gamename37/gamename37.cue</path> <image>C:/images/gamename37.png</image> <path>./gamename12345/gamename12345.cue</path> <image>C:/images/gamename12345.png</image>
In addition this regex S/R can also manage this case :
<path>./gamename1567/aaaaa/bbbbb/ccccc/gamename1567.cue</path> <image>C:/images/gamename1567/aaaaa/bbbbb/ccccc/gamename1567.png</image>
And, after replacement, you would get :
<path>./gamename1567/aaaaa/bbbbb/ccccc/gamename1567.cue</path> <image>C:/images/gamename1567.png</image>
Nice, isn’t it ?
Best regards
guy038
-
-
Thank you, it works :)