skip to Main Content
Talk to a Security Expert Now: (800) 721-9177

Converting Lots of PDFs to TXTs in Ubuntu/Debian

For those of you who are struggling to find a way to convert PDF files into TXT files, here is a quick bash script. There are many alternatives out there, but none were reliable for me. You’ll need to have acroread and ghostscript installed for this to work.

mkdir ps txt
for f in $FILES
echo "Processing $f"
acroread -toPostScript $f ps/
g=`basename $f .pdf`
ps2txt ps/$ > txt/$g.txt

You can also change the second to last line to read
ps2txt ps/$ | grep -v "EXCLUDE" > txt/$g.txt
where EXCLUDE is a line that you want to exclude from each PDF. Please let me know if you have any problems.


This Post Has 0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top