Ubuntu – How to convert all pdf files to text (within a folder) with one command

batchconvertpdftext;

I know that I can convert pdf files to text files one by one like this :

$ pdftotext filename.pdf

But is there a single command that would make that conversion without specifying separate file names so as to convert them all?

I see here, on Wikipedia, that "Wildcards (*), for example $ pdftotext *pdf, for converting multiple files, cannot be used because pdftotext expects only one file name."

Best Answer

The following will convert all files in the current directory:

for file in *.pdf; do pdftotext "$file" "$file.txt"; done