Search code examples
batch-filefindstr

Windows Batch Parse certain text from txt file


Hi I'm trying to make a batch file that will extract the url from the second line in my log.txt file.

Log.txt:

[cli][info] Found matching plugin daisuki for URL http://www.daisuki.net/us/en/anime/watch.GUNDAMUNICORNRE0096.13143.html
[plugin.daisuki][info] Subtitles: http://bngnwww.b-ch.com/caption/35470338/3869/334725220770951/8754371381.xml
Available streams: 1080p (best), 360p (worst), 480p, 720p

I read up on the findstr command and tried findstr /c:xml log.txt and that works great and all but I get this output:

[plugin.daisuki][info] Subtitles: http://bngnwww.b-ch.com/caption/35470338/3869/334725220770951/8754371381.xml

how do i clean the output [plugin.daisuki][info] Subtitles: to get desired output of:

http://bngnwww.b-ch.com/caption/35470338/3869/334725220770951/8754371381.xml

Solution

  • for /f "tokens=3" %A in ('findstr /c:xml log.txt') do echo %A
    

    Use %%A in a batch file. See for /?. This takes text after second space.