Compress PDFs using Python

python

Solution

From the project's GitHub page for pdfsizeopt, which is written in Python:

pdfsizeopt is a program for converting large PDF files to small ones. More specifically, pdfsizeopt is a free, cross-platform command-line application (for Linux, Mac OS X, Windows and Unix) and a collection of best practices to optimize the size of PDF files, with focus on PDFs created from TeX and LaTeX documents. pdfsizeopt is written in Python..."

You can probably easily adapt this to your specific needs.

Problem

So I have a gazillion pdfs in a folder, I want to recursively (using os.path.walk) shrink them. I see that adobe pro has a save as reduced size. Would I be able to use this / how do you suggest I do it otherwise. Note: Yes, I would like them to stay as pdfs because I find that to be the most commonly used and installed fileviewer.

Original source