如何只获取和回显partition_index: SYS18
、linear_start_addr: 0x8020000
、physical_start_addr: 0x8020000
和partition_size: 0x100000
?
此外,根据安卓设备型号不同,scatter.txt可能会有所不同。
我只需要得到scatter.txt
的玻璃钢部分。
partition_index: SYS17
partition_name: metadata
file_name: NONE
is_download: false
type: NORMAL_ROM
linear_start_addr: 0x6020000
physical_start_addr: 0x6020000
partition_size: 0x2000000
region: EMMC_USER
storage: HW_STORAGE_EMMC
boundary_check: true
is_reserved: false
operation_type: INVISIBLE
reserve: 0x00
partition_index: SYS18
partition_name: frp
file_name: NONE
is_download: false
type: NORMAL_ROM
linear_start_addr: 0x8020000
physical_start_addr: 0x8020000
partition_size: 0x100000
region: EMMC_USER
storage: HW_STORAGE_EMMC
boundary_check: true
is_reserved: false
operation_type: PROTECTED
reserve: 0x00
partition_index: SYS19
partition_name: pad
file_name: NONE
is_download: false
type: NORMAL_ROM
linear_start_addr: 0x8120000
physical_start_addr: 0x8120000
partition_size: 0x6E0000
region: EMMC_USER
storage: HW_STORAGE_EMMC
boundary_check: true
is_reserved: false
operation_type: INVISIBLE
reserve: 0x00
发布于 2017-03-09 18:11:37
@echo off&SetLocal EnableDelayEdexpansion
set /a n = 1
for /f "delims=" %%a in (scatter.txt) do (
set "b=%%a"
set "b=!b:partition_index=!"
set "b=!b:linear_start_addr=!"
set "b=!b:physical_start_addr=!"
set "b=!b:partition_size=!"
if not "!b!" equ "%%a" (
if defined flag set /a n+=1
call set str!n!=%%a
)
set "b=!b:partition_name: frp=!"
if "!b!" equ "" set flag=1
)
for /l %%a in (1 1 4) do (
echo !str%%a!
)
pause
发布于 2017-03-09 20:14:32
下面的注释脚本应该可以完成这项工作。请注意,在两个for /F
循环中,delims
略有不同:
@ECHO OFF
SETLOCAL EnableExtensions EnableDelayedExpansion
set "_word=%~1" for debugging purposes
if not defined _word set "_word=frp" default value of partition name
set "_right=" remove variable _right
REM iteration #1: GET sequence number of a data block
set "_index=0"
for /F "tokens=1,* delims=: " %%G in ('
findstr /R "partition_index partition_name" "D:\bat\SO\files\scatter.txt"
') do (
if "%%~G"=="partition_index" set /A _index+=1
if "%%~G"=="partition_name" if "%%~H"=="%_word%" set /A _right=_index
)
if not defined _right (
echo %_word% not found as partition_name
goto :endscript
)
REM iteration #2: USE sequence number of a data block
set "_index=0"
for /F "tokens=1,* delims=:" %%G in ('
findstr /R "partition linear physical" "D:\bat\SO\files\scatter.txt"
') do (
if "%%~G"=="partition_index" set /A _index+=1
if %_right% EQU !_index! echo %%G:%%H
)
:endscript
ENDLOCAL
goto :eof
输出
==> D:\bat\SO\42691448.bat xxx
xxx not found as partition_name
==> D:\bat\SO\42691448.bat metadata
partition_index: SYS17
partition_name: metadata
linear_start_addr: 0x6020000
physical_start_addr: 0x6020000
partition_size: 0x2000000
==> D:\bat\SO\42691448.bat
partition_index: SYS18
partition_name: frp
linear_start_addr: 0x8020000
physical_start_addr: 0x8020000
partition_size: 0x100000
==>
资源(必读):
页面(命令参考) An A-Z Index of the Windows CMD command line
%~G
等特殊页面) Command Line arguments (Parameters)
>>
,2>&1
等特殊页面) Redirectionhttps://stackoverflow.com/questions/42691448
复制相似问题