REM filepath: /C:/Users/sathish/Desktop/AltoUpgrade/7FixVolumeIssue.bat
@echo off

REM Define the lines to check and add
set "LINE1=audio.safemedia.bypass=true"
set "LINE2=audio_safe_volume_state=1"
set "LINE3=audio.safemedia.force=false"
set "LINE4=ro.product.locale=en-US"
set "LINE5=persist.sys.locale=en-US"
set "LINE6=ro.product.locale.language=en"
set "LINE7=ro.product.locale.region=US"
set FILE=/system/build.prop

REM Pull the build.prop file to local machine
adb pull %FILE% build.prop

REM Create a temporary file to store the modified build.prop
copy build.prop build_temp.prop

echo Please wait while the script is updating build.prop... This will take about 20 seconds

REM Check, delete, and add each line
call :check_delete_and_add

REM Push the modified build.prop file back to the device
adb push build_temp.prop %FILE%

REM Set correct permissions
adb shell chmod 644 %FILE%

echo Done.

REM Function to check, delete, and add lines
:check_delete_and_add
setlocal enabledelayedexpansion
for %%L in ("%LINE1%" "%LINE2%" "%LINE3%" "%LINE4%" "%LINE5%" "%LINE6%" "%LINE7%") do (
    set "LINE=%%~L"
    REM echo Processing: !LINE!
    findstr /c:"!LINE!" build.prop >nul
    if !errorlevel! equ 0 (
        findstr /v /c:"!LINE!" build_temp.prop > build_temp2.prop
        move /y build_temp2.prop build_temp.prop >nul 2>&1
        echo !LINE! >> build_temp.prop
        echo !LINE! updated in build.prop
    ) else (
        echo !LINE! >> build_temp.prop
        echo !LINE! added to build.prop
    )
)
endlocal
goto :eof

REM Delete temporary files
del build.prop
del build_temp.prop