How to replace text in text file using bat file script?

后端 未结 3 1506
故里飘歌
故里飘歌 2020-12-18 23:26

So I want to create a script that takes 3 arguments: path to file, exact word to replace, and with what to replace it. How to create such thing?

Generally I want it

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-19 00:07

    Use fnr utility its better than other famous utility since it can search and replace based on regular expressions. Also for the UI lovers you can configure options in UI and it can generate command line string which can then be used in your script. Very easy to use even as command line stirng.

    Find it here http://findandreplace.codeplex.com/

    Also it is single exe without any dependicies, so easy to use.

    Example:

    fnr --cl --dir "" --fileMask "hibernate.*" --useRegEx 
          --find "find_str_expression" --replace "replace_string"
    

提交回复
热议问题