Multiple File Search & Replace?



  • Is it possible to search and replace the same text in multiple files at once?



  • There is an option in the search …search in files
    Specify the search directory …and act!



  • Maybe not a bad opportunity to caution users that there is no undo’ing this operation (Replace in Files) for files that are not currently open with Notepad++!



  • @George-Fisher said:

    multiple files at once

    There’s also the option within the ‘Replace’ function to perform the replacement on “All Opened Documents”. So open all the files within Notepad++ (assuming not too many that it exceeds available memory, otherwise do in groups).

    In this case I would assume the backup options would be in effect so it bypasses the issue Alan mentioned.

    Terry



  • @Terry-R said:

    In this case I would assume the backup options would be in effect

    Well…backups would have to be turned on, but yes I guess they provide some protection from an “oopsy”. But if you use that type of replacement (found on the Replace tab, not the Find in Files tab), then “Undo” will be available (although it is not a “global” undo–you have to physically go to each tab and execute the undo command–which could be a burden if you have a lot of tabs open and affected by the operation).

    It is best to really think about these powerful replace operations BEFORE pressing the button, but I realize sometimes mistakes happen. At least the Replace In Files button makes you confirm it (basically you have to do 2 stupid things instead of just one to screw up). :)



  • @Alan-Kilborn said:

    Well…backups would have to be turned on

    Agreed. Actually the other statement you make is true in ALL cases where a regex is used.
    “…think about these powerful replace operations BEFORE pressing the button…”

    As we are (often) using regex to work on large amounts of data it is extremely important to know what the regex is doing to the data, and if an ooops happens then a method for backing out is equally as important. So whether it’s the built-in backup feature of NPP (turned on of course) or a complete copy of the original files set aside, it all falls on the operator to identify a “plan” before hitting THAT button!

    Terry



  • I appreciate all the input. My usage of the program isn’t all that critical in the grand scheme of things and I’m not looking at massive files. I like to make mods for a game and sometimes need to change a dozen or so files with the same info. By going into each file and making the change I just felt there must be a better way. lol
    Again, thank you all! ;)


Log in to reply