Hi,
please can help a cat ?
I have a .txt tmp_whatsapp.py that is
I need to catch the only code 346360000 (that is a variable) between theCode:#PY <- Needed to identify # #--automatically built-- adm = Avidemux() adm.clearSegments() adm.addSegment(0, 0, 346360000) adm.markerA = 0 adm.markerB = 346360000 adm.setHDRConfig(1, 1, 1, 1, 0)
orCode:adm.addSegment(0, 0, 346360000)
I suppose something like:Code:adm.markerB = 346360000
but this seems don't work.Code:awk.exe "/adm.markerB/{ print $2 }" "c:\tmp_whatsapp.py"
What is the correct way? thanks
+ Reply to Thread
Results 1 to 6 of 6
-
-
You will never learn how to do this if someone has to spoon feed you.
Goolge is your friend, try using it.
Code:awk "/adm.addSegment|adm.markerB/{ sub(/\)/,\"\",$3); print $3 }" "c:\tmp_whatsapp.py"
This works for windows. For Linux/unix make appropriate minor changes.Last edited by jack_666; 5th Feb 2023 at 16:30.
-
https://forum.videohelp.com/threads/377677-Video-batch-files#post2468981
I posted that link many times. You can look in principle there. Once you find a line you have to parse it. Meaning finding a string withing a string. In this case I used tokens and delims:
Code:@echo off set info="c:\tmp_whatsapp.py" set "cat_string=" findstr /b /i /c:"adm.markerB" %info% > "temp.txt" if %errorlevel%==0 call :get_my_cat_string "temp.txt" echo %cat_string% echo press any key to exit ... & pause>nul & exit :get_my_cat_string <temp file> set /p line= < "%~1" for /F "tokens=3 delims= " %%a in ("%line%") do set cat_string=%%a goto :eof
Code:346360000
Code:for /F "tokens=1,2,3 delims= " %%a in ("%line%") do echo %%a, %%b, %%c
Code:adm.markerB, =, 346360000
Last edited by _Al_; 5th Feb 2023 at 17:06.
-
so the point is using subroutines, you can put working subroutines out of the way and just calling them. You do not clutter your main thread with noise, because after some time you do not know what is going on reading script again, so for example you can do this:
Code:@echo off call :parsing_general adm.markerB "c:\tmp_whatsapp.py" parse_my_cat_line echo %parsing_result% echo press any key to exit ... & pause>nul & exit ::this you'd put on the bottom of your script, out of the way :parsing_general <searched string> <source file> <parsing method> set "parsing_result=" findstr /b /i /c:"%~1" "%~2" > "temp.txt" if %errorlevel%==0 call :%3 "temp.txt" goto :eof :parse_my_cat_line <temp file> set /p line= < "%~1" for /F "tokens=3 delims= " %%a in ("%line%") do set parsing_result=%%a goto :eof
-
for example, you downloaded awk, which you have stored somewhere, using unknown exe files, so you might as well make you own bat file called "parsing_general.bat" that will look like this:
Code:REM <searched string> <source file> <parsing method> set "parsing_result=" findstr /b /i /c:"%~1" "%~2" > "temp.txt" if %errorlevel%==0 call :%3 "temp.txt" goto :eof :parsing_B_marker <temp file> example: adm.markerB = 346360000 set /p line= < "%~1" for /F "tokens=3 delims= " %%a in ("%line%") do set parsing_result=%%a goto :eof
Code:@echo off call parsing_general adm.markerB "c:\tmp_whatsapp.py" parsing_B_marker if not defined %parsing_result% call :fail if defined %parsing_result% set Bmarker=%parsing_result% echo press any key to exit ... & pause>nul & exit :fail rem something, set default, end script ... goto :eof
Last edited by _Al_; 5th Feb 2023 at 19:06.
Similar Threads
-
how to insulate a string inside a .txt via batch
By marcorocchini in forum Newbie / General discussionsReplies: 8Last Post: 15th Dec 2022, 14:22 -
How to replace character (string) in batch?
By m0ck in forum Newbie / General discussionsReplies: 1Last Post: 29th Mar 2021, 07:26 -
batch to remove a particular string in a .txt file
By marcorocchini in forum Newbie / General discussionsReplies: 8Last Post: 17th Oct 2019, 19:09 -
how to find and replace string that contain % ?!?
By marcorocchini in forum Newbie / General discussionsReplies: 11Last Post: 18th Feb 2019, 14:08 -
batch that change string values on a .txt file
By marcorocchini in forum Newbie / General discussionsReplies: 8Last Post: 14th Feb 2019, 20:33