Batch file to convert all pdf to text (with xpdf)

I would like to run a batch conversion in a folder with full of pdf files. I have using xPDF and this is the command prompt for a single file: c:\Test\pdftotext -layout firstpdftoconvert.pdf firstpdfconverted.txt Could somebody help please to do it in one go (convert all the pdf files only) using a batch file? Thanks in advance!

asked Jan 23, 2014 at 12:06 47 1 1 gold badge 3 3 silver badges 7 7 bronze badges

If I don't enter the converted text file name, it will be automatically the same as the pdf's name, so this command is enough :c:\Test\pdftotext -layout firstpdftoconvert.pdf

Commented Jan 23, 2014 at 12:12

1 Answer 1

for /r %i in (*.pdf) do "c:\Test\pdftotext" -layout "%i" 

This will work on all pdf files in the current directory.

Be sure to double the % signs if you run this from a batch file.

1 1 1 silver badge answered Jan 23, 2014 at 12:34 56.1k 13 13 gold badges 175 175 silver badges 186 186 bronze badges

Thank you! I have a small problem, I don't know if it will work. I would like to run this batch file on a network drive, not a local hard drive, and with the same code it's not working. Any ideas? This is the command I try to run: for /r %%i in (*.pdf) do pdftotext -layout %%i (works locally, doesn't on the network)

Commented Jan 23, 2014 at 13:41

You may try mapping the network folder to a drive letter (Z:\ for example), and then execute the command from the drive letter.

Commented Jan 23, 2014 at 14:12

It is mapped, the location of the folder: g:\PORTABLES\Internal Order Label\CalCerts\pdftotext.exe Any ideas?