There is another solution, which require a bit more parsing.
I needed to handle a fair amount of files, and to grab for each one the confidence level of each word found; handling file one by one was very slow.
Your post gave me the right path : use a file containing your list, and output result to another file, but do not use TSV or TXt file; they're not splitted nor sorted by file.
Use HOCR instead; it's plain HTML in which you can navigate programatically :
list.txt :
SAMPLE-000.png
SAMPLE-001.png
SAMPLE-002.png
Command line :
tesseract list.txt list hocr
Sample output ( part of, for readability ); list.hocr :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<meta name='ocr-system' content='tesseract 4.1.0' />
<meta name='ocr-capabilities' content='ocr_page ocr_carea ocr_par ocr_line ocrx_word ocrp_wconf'/>
</head>
<body>
<div class='ocr_page' id='page_1' title='image "SAMPLE-000.png"; bbox 0 0 3508 2592; ppageno 0'>
<div class='ocr_carea' id='block_1_1' title="bbox 3283 1170 3313 1477">
<p class='ocr_par' id='par_1_1' lang='eng' title="bbox 3283 1170 3313 1477">
<span class='ocr_caption' id='line_1_1' title="bbox 3283 1170 3313 1477; baseline -307 0; x_size 39.714287; x_descenders 9.9285717; x_ascenders 9.9285717">
<span class='ocrx_word' id='word_1_1' title='bbox 3284 1170 3313 1220; x_wconf 94'>EP</span>
( ... )
</span>
</p>
( ... )
</div>
</div>
<div class='ocr_page' id='page_2' title='image "SAMPLE-001.png"; bbox 0 0 2592 3508; ppageno 1'>
<div class='ocr_carea' id='block_2_1' title="bbox 792 194 1861 225">
<p class='ocr_par' id='par_2_1' lang='eng' title="bbox 792 194 1861 225">
<span class='ocr_header' id='line_2_1' title="bbox 792 194 1861 225; baseline 0.006 -4; x_size 39.866665; x_descenders 9.9666662; x_ascenders 9.9666662">
<span class='ocrx_word' id='word_2_1' title='bbox 792 194 828 221; x_wconf 96'>17</span>
( ... )
</span>
</p>
</div>
( ... )
</div>
</body>
</html>
You can notice some interesting attributes in markup :
- title='image "SAMPLE-000.png"; bbox 0 0 3508 2592; ppageno 0'
- x_wconf which seems to stand for confidence
etc. You "just" have to parse it with your favorite tool.