Search code examples
notepad++

Notepad++ replace using variables


In Notepad++ I need to find every instance of the following:

<ApplicationPath>F:\software\VARIABLEA.zip</ApplicationPath>

with the following:

<ApplicationPath>F:\Games\VARIABLEA\VARIABLEA.m3u</ApplicationPath>

Where the filename in the first example, VARIABLEA, is to be used to modify the application path by inserting the VARIABLEA text where indicated.

Unfortunately, I can't wrap my head around how to accomplish this. Your pointers are appreciated, thank you.


Solution

  • You can try using a regular expression search and replace.

    Search this: <ApplicationPath>F:\\software\\([^.]*)\.zip<\/ApplicationPath>

    and replace with: <ApplicationPath>F:\\Games\\$1\\$1.m3u</ApplicationPath>.

    If you want to understand how this expression is built, I suggest you copy and paste it on here, since it explains it better than I can. But, basically, whatever your filename is, it captures it and uses it in the resulting path where the $1 are.