How can I run this batch script on filenames with space and “(” “)”?
:Start
@Echo off
Set _SourcePath=C:\tifs\*.tif
Set _OutputPath=C:\txts\
Set _Tesseract="C:\Program Files\Tesseract-OCR\tesseract.exe"
:Convert
For /F "usebackq delims=" %%A in (%_SourcePath%) Do Echo Converting %%A...&%_Tesseract% %%A %_OutputPath%%%~nA
:End
Set "_SourcePath="
Set "_OutputPath="
Set "_Tesseract="
You have 2 problems:
1) You need some additional quotes.
2) You are using the wrong form of FOR. Your code is using the /F option with an unquoted IN() cluase. This attempts to read the contents of a file, which can’t possibly work because your name includes a wildcard. I think you want a listing of .TIF files which is best done using the simple form of FOR (no /F option).