[Tutor] Add metadata to a dir of files.

Tim Golden mail at timgolden.me.uk
Thu Feb 22 18:28:44 CET 2007


> Here's my problem: I have a directory full of about 2,000 pdf files. I want to be able to add the 
> same comment to the "Category" field of each file (in the document properties of the file). So I am 
> looking to batch process pdf files (or any filetype, i guess) to add some metadata.

I'm assuming here that we're talking about the PDF's
own metadata rather than, say, the additional stuff
which Windows allows in Alternate Data Streams? If
so, then a combination of PyPDF:

   http://pybrary.net/pyPdf/

and the builtin os, glob, os.path modules:

   http://docs.python.org/lib/module-os.html
   http://docs.python.org/lib/module-os.path.html
   http://docs.python.org/lib/module-glob.html

might suit the case.

TJG


More information about the Tutor mailing list