I am really confused with something. I am making a batch file that can can display a specific line that I want. For example there is file hi.txt
Content of file -
ro.build.id=KOT49H
ro.build.display.id=XXX_ROM_v1
ro.build.version.incremental=eng.mudingyu.1408084583
ro.custom.build.version=XOLO_8x-1000_0815.v009
ro.internal.version=J608_XOLO_N1A_V0.8.7_S08015
ro.internal.version.rgk=J608_XOLO_N1A_V0.8.7_S08015
ro.build.version.sdk=19
ro.build.version.codename=REL
ro.build.version.release=4.4.4
ro.build.date=Fri Aug 15 14:39:45 CST 2014
ro.build.date.utc=1408084785
As here you can see the file content. Now say I want to print ONLY this piece of information on my screen when batch is executed
"4.4.4" from this line "ro.build.version.release=4.4.4"
I managed to pull of code for the 2nd line
ro.build.display.id=XXX_ROM_v1
When I execute batch I see this
XXX_ROM_V1
Code I used
set "build.prop="
for /F "skip=3 delims=" %%i in (WORKING_FOLDER\system\build.prop) do if not
defined build.prop set "build.prop=%%i"
echo.
echo "%build.prop%"
echo.
echo Enter the name you want to choose
set /p name=
echo Backing up old build.prop...
md C:\Kitchen\temp
copy C:\Kitchen\WORKING_FOLDER\system\build.prop C:\Kitchen\temp
cd C:\Kitchen\temp
cd C:\Kitchen\WORKING_FOLDER\system
build.prop.new (
for /f "tokens=1* delims==" %%A in (build.prop) do (
if "%%A" == "ro.build.display.id" (
echo ro.build.display.id=%name%
) else (
echo %%A=%%B
)
)
)
move /y build.prop.new build.prop >nul
build.prop.new (
for /f "tokens=1* delims==" %%A in (build.prop) do (
if "%%A" == "ro.build.id" (
echo ro.build.id=%name%
) else (
echo %%A=%%B
)
)
)
move /y C:\Kitchen\temp\build.prop.new
C:\Kitchen\WORKING_FOLDER\system\build.prop >nul
echo Changed value of ro.build.display.id to " %name% "
echo.
set "build.prop="
for /F "skip=3 delims=" %%i in (WORKING_FOLDER\system\build.prop) do if not
defined build.prop set "build.prop=%%i"
echo In build.prop now the current name of ROM is
echo.
echo Current ROM Name = %name%
Here as you see in first line I print the name using the line command function and also took input from user to change the name so it became easy to print the file name but in some other files the line "ro.build.display.id" is not always on 4th. So my question is what logic or whatever can be done in order to print the particular term on screen that I wish to print without prompting user to enter new file name just print that specific piece of information
eg The OUTPUT I want
The Android version is "4.4.4"
EG Say I want to print "4.4.4" only from the file above how can I do it? Using findstr or anything please help really appreciated.
whew - that was a lot to read for a quite simple question.
for /f "tokens=2 delims==" %%i in ('find "ro.build.version.release" hi.txt') do set release=%%i
echo The Android version is "%release%"
Find the correct line and tokenize it with =
as delimiter.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.