wz.wang | 6c46070 | 2024-07-01 10:20:35 +0800 | [diff] [blame^] | 1 | @echo off
|
| 2 |
|
| 3 | set item=
|
| 4 | set filepath=
|
| 5 | set section=
|
| 6 | setlocal EnableDelayedExpansion
|
| 7 | if not "%~1"=="" (
|
| 8 | set filepath=%1
|
| 9 | ) else goto :file_err
|
| 10 | if not exist %filepath% goto :file_err
|
| 11 | if 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
|
| 16 | if 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 | )
|
| 21 | setlocal disableDelayedExpansion
|
| 22 | set ×ֶοªÊ¼=
|
| 23 | for /f "usebackq delims=[]" %%i in (`find /i "%section%" /n %filepath%`) do set ×ֶοªÊ¼=%%i
|
| 24 | for /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 | )
|
| 35 | goto :eof
|
| 36 |
|
| 37 | :section
|
| 38 | setlocal disableDelayedExpansion
|
| 39 | for /f "usebackq delims== skip=2" %%i in (`find /i "[" %filepath%`) do echo %%i
|
| 40 | goto :eof
|
| 41 |
|
| 42 | :file_err
|
| 43 | setlocal disableDelayedExpansion
|
| 44 | echo.
|
| 45 | echo %1ÎļþδÕÒµ½»òδÊäÈë!
|
| 46 | echo.
|
| 47 | goto :eof |