How do I create a batch file that reads a file and writes a substring to another file?

I currently have an exported text file ( output.txt

) from the Clear-Case command that I need to parse. It looks like this:

Comparing the following:
  R1.PROD.V1@\VOB_pvob
  R2.PROD.V1@\VOB_pvob
Differences:
>> M:\ACME_PROD\src\ACME@@
>> M:\ACME_PROD\src\ACME\file 2.txt@@
>> M:\ACME_PROD\src\ACME\file 1.txt@@
>> M:\ACME_PROD\src\ACME\file 3.txt@@

      

What I would like to do is use the findstr command to filter the lines between the lines " >>

" and " @@

" to get an output file that looks like this (with quotes if possible:

"M:\ACME_PROD\src\ACME"
"M:\ACME_PROD\src\ACME\file 2.txt"
"M:\ACME_PROD\src\ACME\file 1.txt"
"M:\ACME_PROD\src\ACME\file 3.txt"

      

I'm new to writing batch files, so I'm not sure exactly where to start. I was able to find code that can go through the lines of a text file and separate findstr command code, but I'm stuck trying to put it all together!

Respectfully,

Andrew

+2


source to share


1 answer


Here you go

setlocal enabledelayedexpansion
for /f "skip=1 tokens=* delims=> " %%a in ('"findstr /r [\w^>*] output.txt"') do (
set line=%%a
set line=!line:@=!
echo "!line!" >>new.txt
)

      



Filtered rows will be output to new.txt

.

+2


source







All Articles