I have multiple text files that contains 3 lines of information that I want to output as one single line for each file
Example
File1.txt contains
User: "John"
Date: "13-March-2017"
Time: "10.30am"
Remarks: "xcvsfas"
File2.txt contains
User: "Mary"
Date: "13-March-2017"
Time: "11.30am"
Remarks: "xerteyas"
My expected output is as follows
c:\temp\file1.txt:User: "John"; Date: "13-March-2017"; Time: "10.30am"
c:\temp\file2.txt:User: "Mary"; Date: "13-March-2017"; Time: "11.30am"
I tried
findstr /s /i "user date time:" %inputfolder%\*.* > %outputfolder%\final.txt
I'm assuming all your .txt are in the same folder and only them. Then I get the first three lines of each file and print them in one line by using the
set
command like:I tested with the input you gave and the result is:
Hope it helps.
EDIT: Code modified per new specifications posted in a comment in other answer...
:(
You could loop through the files by a
for
loop and do the search individually -- like this:The fields
User:
,Date:
andTime:
are returned in the original order they appear in every file.