本帖最后由 77七 于 2023-8-17 20:40 编辑
- @echo off
- set "file=D:\test\1.ini"
- rem 批处理保存为ansi编码格式。4、5行注释其中一行,4为选择,5为切换。
- rem choice /c ab /m "choose"
- find "cps=mihoyo" <"%file%" 1>nul
- if %errorlevel% equ 1 (
- set str_cps=mihoyo
- set str_channel=1
- set str_sub_channel=1
- ) else (
- set str_cps=bilibili
- set str_channel=14
- set str_sub_channel=0
- )
- (for /f "tokens=1* delims=:" %%a in ('findstr /n .* "%file%"') do (
- (for /f "tokens=1* delims==" %%c in ("%%b") do (
- if "%%c" equ "cps" (
- echo %%c=%str_cps%
- ) else if "%%c" equ "channel" (
- echo %%c=%str_channel%
- ) else if "%%c" equ "sub_channel" (
- echo %%c=%str_sub_channel%
- ) else echo %%b
- )) || echo=
- ))>tmp.ini
- move /y tmp.ini "%file%"
复制代码
|