我的问题是使用Windows命令行解析ini文件。
我尝试从文件中删除包含所有键的部分时卡住了。此部分的名称已知并保存在变量中。
我试图保存行(开始,结束)以删除它们之间的东西,但它对我不起作用。
这里有人可以帮助我吗?
修改
以下是ini文件的示例:
[Example]
cycle = value
cycle2 = value
cycle_bu = value
[Example2]
key1 = value
key2 = value
key3 = value
key4 = value
[something3]
key1 = value
key2 = value
key3 = value
key4 = value
key5 = value
key6 = value
答案 0 :(得分:1)
http://www.robvanderwoude.com/sourcecode.php?src=readini_nt
你能检查一下这是否可行吗?
修改强> 这未经过测试:
break >new.ini
set skip_this_section=[something]
set skip_flag=0
for /f %%I in (myini.ini) do (
call :print_to_file %%I
)
goto :eif
:print_to_file
setlocal enabledelayedexpansion
set line=%1
set first_char=!line:~0,1!
if "!first_char!" EQU "[" (
if "!line!" EQU "!skip_this_section!" (
set skip_flag=1
) else (
set skip_flag=0
)
)
endlocal & set skip_flag=%skip_flag%
if %skip_flag% EQU %0% (
echo %1 >> new.ini
)
答案 1 :(得分:0)
有一个CLI crudini
用于按组和键来处理ini条目: