I have more than 20 files i.e. ra1.tif to ra20,tif and ra1.tr to ra20.tr files Require batch file to execute
the following two commands as follows;
1)tesseract rao1.tif rao1 nobatch box.train logfile
2)mftraining.exe rao1.tr rao2.tr rao3.tr etc.
regards,
sriranga(79yrsold)
Let's get it straight. You have files named RA1.TIF to RA20.TIF and RA1.TR to RA20.TR yet you want to access files named RAO1.TIF and RAO1.TR etc. Doesn't make sense even for a 79 year old.. Age is no excuse..
Please come back & tell us if your problem is resolved.
sorry. I realized my typing mistake. Kindly read rao1.tif etc and rao1.tr AS Ra1.tif etc and Ra1.tr etc. Thanks to Wahine for pointing out my typos in the post. Kindly help me to solve the
problem.
This script is untested. @echo off cls setlocal set nbr=1 :looptif tesseract ra%nbr%.tif rao1 nobatch box.train logfile set /a nbr+=1 if %nbr% gtr 20 (goto tr ) else ( goto looptif ) :tr set nbr=1 :looptr mftraining.exe ra%nbr%.tr set /a nbr+=1 if %nbr% gtr 20 (goto :eof ) else ( goto looptr )
Please come back & tell us if your problem is resolved.
;;Modified code below - kindly correct if there is any mistake for which I shall be thankful to you.I appreciate your good program which will serve my purpose.Awaiting your further valuable guidance.
::@echo off
cls
setlocalset nbr=1
::total number of files required for process is 2 eg: rao1.tif rao1.box and rao2 rao.box As such i changed "%nbr% gtr20" to "%nbr% = gtr2":looptif
tesseract rao%nbr%.tif rao%nbr% nobatch box.train logfile
rename tesseract.log rao%nbr%tesseract.logset /a nbr+=1
if %nbr% =gtr2 (goto :box :: gtr ?(presumed gtr2 =total number of 2 files)
) else (
goto looptif
)
:box
set nbr=1:loopbox
unicharset_extractor.exe rao%nbr%.box
set /a nbr+=1
if %nbr% =gtr2 (goto :tr
) else (
goto loopbox
):tr
set /a nbr+=1
:looptr
mftraining.exe rao%nbr%.tr
cntraining.exe rao%nbr%.tr
set /a nbr+=1
if %nbr% =gtr2 (goto :rename
) else (
goto looptr
): rename
rename unicharset rao.unicharset
rename inttemp rao.inttemp
rename pffmtable rao.pffmtable
rename microfeat rao.microfeat
rename normproto rao.normprotocombine_tessdata.exe ./rao.
copy rao.traineddata tessdata\.
pause
=================================================
OUTPUT OF CMD(without using ABOVE bat file)=
::Extract of output for two files viz.rao1.tif/box and rao2.tif/box.
M:\NRES>tesseract rao1.tif rao1 nobatch box.train logfile
Number of found pages: 1.M:\NRES>rename tesseract.log rao1.tesseract.log
M:\NRES>tesseract rao2.tif rao2 nobatch box.train logfile
Number of found pages: 1.M:\NRES>rename tesseract.log rao2.tesseract.log
M:\NRES>unicharset_extractor.exe rao1.box rao2.box
Extracting unicharset from rao1.box
Extracting unicharset from rao2.box
Wrote unicharset file ./unicharset.M:\NRES>mftraining.exe rao1.tr rao2.tr
Reading rao1.tr ...
rao1 has no defined properties.
Reading rao2.tr ...
rao2 has no defined properties.Writing Merged Microfeat ...Done!
M:\NRES>cntraining.exe rao1.tr rao2.tr
Reading rao1.tr ...
Reading rao2.tr ...
Clustering ...Writing normproto ...
M:\NRES>rename unicharset rao.unicharset
M:\NRES>rename inttemp rao.inttemp
M:\NRES>rename microfeat rao.microfeat
M:\NRES>rename pffmtable rao.pffmtable
M:\NRES>rename normproto rao.normproto
M:\NRES>combine_tessdata.exe rao.
Combining tessdata files
TessdataManager combined tesseract data files.
Offset for type 0 is -1
Offset for type 1 is 108
Offset for type 2 is -1
Offset for type 3 is 45912
Offset for type 4 is 4896476
Offset for type 5 is 4906760
Offset for type 6 is -1
Offset for type 7 is -1
Offset for type 8 is -1
Offset for type 9 is -1
Offset for type 10 is -1
Offset for type 11 is -1
Offset for type 12 is -1
M:\NRES>copy rao.traineddata tessdata\.
Overwrite tessdata\.\rao.traineddata? (Yes/No/All): y
1 file(s) copied.
Wahin, Awaiting your confirmation of modified codes according my requirement - whether it is correct or not. If not, correct kindly correct the same and intimate me earliest possible.Thank you.
-Sriranga(79yrs)
if %nbr% =gtr2 appears at least three times in the script you posted. I do not understand where you got this from. The format is incorrect, see the script I posted. By altering the number of files you have changed your original specifications. As there is no possibility of my testing the script you posted I regret I cannot advise you further.
Good luck.
Please come back & tell us if your problem is resolved.
Wahine,
Thanks for the prompt response. It is true that number of files proposed to use was 20. For testing purpose, the number of files used is 2 files. In your code, you had indicated as "gtr20" -which I had presumed(may be mistake) that number of files proposed to be use viz. 20 files have been indicated as "gtr20" by you. Since I am using only two files for testing purpose. I changed "gtr20" to "gtr2" thinking I am limiting the number of files 20 to 2 only for testing purpose.
In fact, I am newbie to Batch, all done by guess method. for which kindly excuse me. Moreover I am not programmer nor developer. The batch file is badly required for generating traineddata files for Kannada OCR project - for benefit of employees working in govt as well as private. As a SPECIAL CASE, reconsider my request to rectify my codes wherever necessary to enable me to use the same based on the output of CMD furnished at the bottom of the codes. In nutshell, where/which line I have to modify the number of files proposed to use say more than 20files or less than 20 files in your valuable codes?
Awaiting your valuable guidance.
With warmest Regards,
-sriranga(79yrs)
Wahin,
the following list of commands in CMD are used for generating traineddata file for tesseract-ocr project.I hope you are convinced and help me to create batch file for any number of files specified by the user.Now it is clear to you now.::files used for testing= 3
::No.of tif files= rao1.tif, rao2.tif, rao3.tif
::No.of box files= rao1.box, rao2.box, rao3.box
===========================================
tesseract rao1.tif rao1 nobatch box.train logfile
rename tesseract.log rao1.tesseract.logtesseract rao2.tif rao2 nobatch box.train logfile
rename tesseract.log rao2.tesseract.logtesseract rao3.tif rao3 nobatch box.train logfile
rename tesseract.log rao3.tesseract.logunicharset_extractor.exe rao1.box rao2.box rao3.box
mftraining.exe rao1.tr rao2.tr rao3.tr
cntraining.exe rao1.tr rao2.tr rao3.tr
:: list of output of above commands are as follows=
:: unicharset,
:: inttemp
:: Microfeat
:: pffmtable
:: normprotorename unicharset rao.unicharset
rename inttemp rao.inttemp
rename microfeat rao.microfeat
rename pffmtable rao.pffmtable
rename normproto rao.normproto
combine_tessdata.exe rao.
copy rao.traineddata tessdata\.
pause
Awaiting your valuable guidance.
attention of experts,
please see above my posts .No solution forthcoming!
awaiting valuable guidance please.
-sriranga(79yrs old)
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |