blob: 7e793e5332b7db2a44cfa32812508aa63a9895ad [file] [log] [blame]
wz.wang6c460702024-07-01 10:20:35 +08001@echo off
2
3set item=
4set filepath=
5set section=
6setlocal EnableDelayedExpansion
7if not "%~1"=="" (
8 set filepath=%1
9) else goto :file_err
10if not exist %filepath% goto :file_err
11if not "%~2"=="" (
12 set section=%2
13 if "!section:~0,1!"==""^" set section=!section:~1!
14 if "!section:~-1!"==""^" set section=!section:~0,-1!
15) else goto :section
16if not "%~3"=="" (
17 set item=%3
18 if "!item:~0,1!"==""^" set item=!item:~1!
19 if "!item:~-1!"==""^" set item=!item:~0,-1!
20)
21setlocal disableDelayedExpansion
22set ×ֶοªÊ¼=
23for /f "usebackq delims=[]" %%i in (`find /i "%section%" /n %filepath%`) do set ×ֶοªÊ¼=%%i
24for /f "usebackq tokens=1* delims== skip=%×ֶοªÊ¼%" %%i in (`type %filepath%`) do (
25 set a=%%i
26 setlocal EnableDelayedExpansion
27 if "!a:~0,1!"=="[" goto :eof
28 if not "!a:~0,1!"==";" (
29 setlocal disableDelayedExpansion
30 for /f "delims=;" %%x in ("%%i=%%j") do (
31 if not DEFINED item (echo %%x) else (if /i "%%i"=="%item%" echo %%x)
32 )
33 )
34)
35goto :eof
36
37:section
38setlocal disableDelayedExpansion
39for /f "usebackq delims== skip=2" %%i in (`find /i "[" %filepath%`) do echo %%i
40goto :eof
41
42:file_err
43setlocal disableDelayedExpansion
44echo.
45echo %1ÎļþδÕÒµ½»òδÊäÈë!
46echo.
47goto :eof