'Batch find and replace only on lines that contain a specific text [closed]

I'm trying to do a "find and replace" into a text file from batch but only on specific lines, as such:

Before:

7,U7k956ykBJ,"GenericLine"
7,SwNZVX7SwPA2,"GenericLine"
7,783bMsWVSJZ8,"LineToReplace"
7,PiUcP84ujF5z,"GenericLine"

After:

7,U7k956ykBJ,"GenericLine"
7,SwNZVX7SwPA2,"GenericLine"
2,783bMsWVSJZ8,"LineToReplace"
7,PiUcP84ujF5z,"GenericLine"

So, to be clearer, I'd like to replace that "7," to a "2," if the line contains "LineToReplace"



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source