Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A Python script for stripping out metadata from a PDF file.
import os
from PyPDF2 import PdfFileReader, PdfFileMerger
files_dir = os.getcwd()
if 'stripped' not in os.listdir(files_dir):
os.mkdir('stripped')
for f in os.listdir(files_dir):
if f.split('.')[-1] == 'pdf':
merger = PdfFileMerger()
merger.append(PdfFileReader(f, 'rb'))
merger.write('stripped/{0}'.format(f))
@positivedefinite

This comment has been minimized.

Copy link

@positivedefinite positivedefinite commented Jul 30, 2019

this isn't working anymore :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment