[Solved] Import plain text from > 300 PDF files & then export each file

I have about 300 PDF files in a directory & each file contains both images and text. I want to import the plain text from each of those files and then export the data to .txt files with the same name as the PDF files.

I can do this one by one but is there is a way to batch process all 300 files?.

Hi v m

This should do it. Please first test on a subset of the files in a different directory.

dir = "path/to/directory"
files = FileNames["*.pdf", dir]

Export[FileNameJoin[{dir, FileBaseName@#1 <> ".txt"}],  Import[#, "Plaintext"]] & /@
files

I tried it and worked with no issues at all. This was exactly what I was looking for. Thank you!