how to read file name with spaces?
Posted: 09 Feb 2018 14:42
Below code is to convert all pdf files to txt.
It could not read the filenames with space.
If fine name is XXXX_QRRPS Tran book - 0utgoing-en-in_2018-02-09T024757245Z.pdf, it reads XXXX_QRRPS.
can any one please see?
Code: Select all
@echo off &setlocal
set "pdfToText=C:\Users\u595142\Desktop\xpdf32\pdftotext.exe" & rem source for the pdftotext exe
set "allPdfFiles=C:\Users\u595142\Desktop\allPdfFiles" & rem source pdf folder
set "allTxtFiles=C:\Users\u595142\Desktop\allTxtFiles" & rem source txt folder
if not exist "%allTxtFiles%" mkdir "%allTxtFiles%"
for /f %%v in ('dir /b %allPdfFiles%\*.pdf') do (
"%pdfToText%" "%allPdfFiles%\%%v" "%allTxtFiles%\%%~nv.txt" >NUL 2>&1 || echo Error converting %%v
)
endlocal
exit/B
If fine name is XXXX_QRRPS Tran book - 0utgoing-en-in_2018-02-09T024757245Z.pdf, it reads XXXX_QRRPS.
can any one please see?