Run Craft Find and Replace via Console
You can write a plugin that does this.

Use https://pluginfactory.io/ and check the "Console Command" checkbox and it will generate the boilerplate for you.

Your "Find and Replace" command would follow similar logic to what the FindAndReplaceTask's runStep() method does.