Search code examples
stringbatch-filecmdfindfindstr

batch file read and store in a text file string


So i have multiple files that when opened it looks something like this

 THis is header
 A|0003920449219349||||B|skej24ie422|
 F|ddawejaskld

My question is how can I store the string in the second line specifically 0003920449219349(or the number between |) to a seperate text file (>storehere.txt)


Solution

  • for /f "tokens=2,3 delims=|" %%a in (*.txt) do if "%%b" neq "" echo %%a>>storehere.txt
    

    ... assuming, the format is really, what your example is like.