So i've been looking at articles to see how to get this to work but everything has been going over my head. I'm trying to create a bat file that finds a game commandline.txt and changes a certain commandline for example a resolution
-width=1280 -height=720
to
-width=800 -height=400
for exmaple
and for it to save as the same .txt
I have written this for an example of code i want to use in a similar fashion and for you to get an idea of what i'm doing
@echo off
:MENU
CLS
echo+
echo 1 - game1
echo 2 - game2
echo+
echo+
SET /P MainMenuInput=Enter an option and press ENTER:
if %MainMenuInput% == 1 (
findstr "" "X:\game1\commandline.txt"
echo.%str%
set str=%str:-width=1280 -height=720=-width=800 -height=400%
echo.%str%
)
GOTO :MENU
if %MainMenuInput% == 2 (
findstr "" "X:\game2\commandline.txt"
echo.%str%
set str=%str:-width=1280 -height=720=-width=800 -height=400%
echo.%str%
)
GOTO :MENU
basically i have 2 games - i select number 1 which is game 1 and then it should change the width and height
So if i change it to this, it still doesn't work
@echo off
:MENU
CLS
echo+
echo 1 - Dev_NG
echo 2 - Dev_NG-Live
echo+
echo+
SET /P MainMenuInput=Enter an option and press ENTER:
if %MainMenuInput% == 1 (
set "search=-width=1280"
set "replace=-width=800"
set "textFile=%SettingFile%.txt"
for /f "delims=" %%i in ('type "%X:\game1\commandline.txt%" ^& break ^> "%X:\game1\commandline.txt%" ') do (
set "line=%%i"
setlocal enabledelayedexpansion
set "line=!line:%search%=%replace%!"
>>"%textFile%" echo(!line!
endlocal)