I have 159 PDF in a folder with nothing else in it. I need them all converted to raw text. I found the documentation for doing them one at a time, which worked. To do them in bulk I tried this

    Export[(C : \\ filepath \\ #.txt) & /@ Range[159], 
  Import["C:\\filepath\\*.pdf", "Plaintext"], "TEXT"];

which did not work. I can deal with the converted files as just separately numbered but if the original PDF filename survived as the name for the .txt file that would be better.

@Syed - Just figured out your hint. This worked perfectly!!

 ToString[#], ".txt"], ptVers[[#]], "TEXT"] & /@ Range[160];



1 Answer 1


I created a folder pdftest inside my Documents folder and put three pdf files there with one line of text each to create a MWE.

enter image description here

files = FileNames["pdftest/*.pdf"]
{"pdftest\\I am file no 1.pdf", "pdftest\\I am file no 2.pdf", \
"pdftest\\I am file no 3.pdf"}
Import[#, "Plaintext"] & /@ files

{"I am file no 1 ", "I am file no 2 ", "I am file no 3 "}

From here, you can choose to StringJoin the individual items in the list or use as required.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.