2

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!

Ismo
  • 47
  • 1
  • 3
  • 7
  • 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 – Ismo Jan 23 '14 at 12:12

1 Answers1

6

Combining your question with this answer iterating over files of a directory:

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.

Community
  • 1
  • 1
marapet
  • 54,856
  • 12
  • 170
  • 184
  • 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) – Ismo Jan 23 '14 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. – marapet Jan 23 '14 at 14:12
  • It is mapped, the location of the folder: g:\PORTABLES\Internal Order Label\CalCerts\pdftotext.exe Any ideas? – Ismo Jan 23 '14 at 14:15
  • Look at the edited code above - it supports long paths and filenames now. – foxidrive Jan 23 '14 at 14:44