title: How to extract the title of a PDF document from within a script for renaming?
body: <p>I have thousands of PDF files in my computers which names are from <code>a0001.pdf</code> to <code>a3621.pdf</code>, and inside of each there is a title; e.g. "aluminum carbonate" for <code>a0001.pdf</code>, "aluminum nitrate" in <code>a0002.pdf</code>, etc., which I'd like to extract to rename my files.</p>
  
  <p>I use this program to rename a file:</p>
  
  <pre><code>path=r"C:\Users\YANN\Desktop\..."
  
  old='string 1'
  new='string 2'
  
  def rename(path,old,new):
      for f in os.listdir(path):
          os.rename(os.path.join(path, f), os.path.join(path, f.replace(old, new)))
  
  rename(path,old,new)
  </code></pre>
  
  <p>I would like to know if there is/are solution(s) to extract the title embedded in the PDF file to rename the file? </p>