title: convert batch of pdf to text using pdftools
body: <p>I'm tying to convert 1000 pdfs to text for data analysis. I'm using the package pdftools. </p>
  
  <p>I have been able to convert 2 pdf using the following code:</p>
  
  <pre><code>library(pdftools)
  file_list &lt;- list.files('pdf', full.names = TRUE, pattern = 'pdf')
  
  for(i in 1:length(file_list)){
    temp &lt;- pdf_text(file_list[i])
    temp &lt;- tolower(temp)
  
    file_name = paste(file_list[i], '.txt')
    sink(file_name)
    cat(temp)
    sink()
  
  }
  </code></pre>
  
  <p>but when I add more than 2 I get the following error: </p>
  
  <pre><code>" Error in poppler_pdf_text(loadfile(pdf), opw, upw) : PDF parsing failure." 
  </code></pre>
  
  <p>also, I would like the final text file to be only "file_name.txt" right now i'm getting "file_name.pdf .txt"</p>
  
  <p>thanks, </p>