1

The problem I have, is I have many .json-files in many subdirectories. They all have:

"equalToXml" : "Something else..."

(The something else part takes up more than one line)

What I want to do, is to simply change "equalToXml" to "contains", so I would have:

"contains" : "Something else..."

Sounds like a pretty easy operation, but I don't seem to get it worked, and I can't really find anything, which works on the web.

Is this even possible with Batch? Or what would be an easy alternative, since I already have other batch-scripts, which get called before.

Thanks!

user5417542
  • 3,146
  • 6
  • 29
  • 50
  • 1
    Find a command line too, E.g. [FART.EXE](http://sourceforge.net/projects/fart-it/) – Alex K. Oct 12 '15 at 12:13
  • 5
    Possible duplicate of [How can you find and replace text in a file using the Windows command-line environment?](http://stackoverflow.com/questions/60034/how-can-you-find-and-replace-text-in-a-file-using-the-windows-command-line-envir) – Alexandre Beaudet Oct 12 '15 at 12:17
  • Thanks for the tip, I now figured out how to do it: That did it for me: http://www.computing.net/answers/programming/batch-file-to-replace-text-in-file/20070.html Just needed to adjust it, to do this for many files. But the problem I now have, is that my JSON-Files aren't formatted anymore. How can I pretty print them? – user5417542 Oct 12 '15 at 13:27

2 Answers2

0

Check replacer.bat

for /r "C:\root_dir" %%# in (*.json) do (
    call replacer.bat "%%~f#" "equalToXml"  "contains"
)

more powerful solutions are JREPL and FindRepl.

npocmaka
  • 55,367
  • 18
  • 148
  • 187
0

A long list of programs that can help with json search and replace here: https://stackoverflow.com/a/49011455/2440

I found jj to be perfect for my simple needs.

Sire
  • 4,086
  • 4
  • 39
  • 74