How to extract the title of a PDF document from within a script for renaming?

前端 未结 6 1768
长情又很酷
长情又很酷 2021-02-01 21:34

I have thousands of PDF files in my computers which names are from a0001.pdf to a3621.pdf, and inside of each there is a title; e.g. \"aluminum carbona

6条回答
  •  忘掉有多难
    2021-02-01 21:44

    What you need is a library that can actually read PDF files. For example pdfrw:

    In [8]: from pdfrw import PdfReader
    
    In [9]: reader = PdfReader('example.pdf')
    
    In [10]: reader.Info.Title
    Out[10]: 'Example PDF document'
    

提交回复
热议问题