Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

How can we extract lines appearing between { } in text file through batch file.

Text file would be in format:

Name : ABC
Place : xyz
Data :dd/mm/yyyy

{"return":"good","message":"ABC is present in xyz place","SSN":"-----------------345679HISKWBXMVTXVEULWXVC
VBXSWGVXBWSDCXLWUDV"}

I tried using the below code snippet, However it lists all the contents of text file . How can we extract the contents within {}

for /f "tokens=*" %%x in (filename) do set extract=!extract!%%x

question from:https://stackoverflow.com/questions/66061821/to-extract-lines-appearing-inbetween-in-text-file-through-batch-file

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
485 views
Welcome To Ask or Share your Answers For Others

1 Answer

This might help you:

@echo off
for /f "usebackq tokens=1 delims={}" %%a in ("Whateverfile.txt") do set "data=%%a"
echo %data%

type for/? in cmd for more info or For-loop


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...