0

I am using a program which checks a config file at every start with the given settings, I am editing a specific line inside the config file very often to find out which option is the best. I wanna add a option to my batch script which asks me for a input that I type inside the command prompt and replaces it with the current text on that line inside the file. The line inside the config file that I want to replace is called max_items: 2. I basically just wanna replace the number everytime I chose the option inside my batch script. I already heard of a text command utility called FART but I don't know if it can really help me with the script that I wanna add to my batch file bc it should ask for a input and replace it with that input. I hope someone has a Idea and can help me out

Sneazy好
  • 1
  • 1
  • Please choose a different scripting language for your task. A Windows `.cmd` script or a `.bat`ch file was not designed to modify the content of a file. It would need to replace the entire content of the file, _(i.e. rewrite a new file complete with your change)_. Other built-in scripting languages, like Windows Scripting Host, _(vbscript/jscript)_, and PowerShell are capable of directly modifying just the string you require. Also there are already hundreds of examples on StackOverflow which perform your task, and which you should locate easily using the search engine at the top of the page. – Compo May 01 '22 at 19:32
  • @compo Thx for your hint, I didn't know abt vbscripts before tbh. I found a script which replaces text perfectly, the only problem is that it doesn't work if I have a space or a underline within the text that I want to replace. For example `max_items: 2` to `max_items: 4`. I am using the vbscript from this question: https://stackoverflow.com/questions/60034/how-can-you-find-and-replace-text-in-a-file-using-the-windows-command-line-envir – Sneazy好 May 01 '22 at 20:17
  • If you have an issue with a specific piece of code Sneazy好, then you should, in the first instance, try to seek help from the member who posted such code. Your next course of action should that fail, would be to submit that code by way of [edit], along with the source file content and details, and a full explanation of how the results do not meet the expectation. – Compo May 02 '22 at 00:31

0 Answers0