Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save erral/4eb23da94973207e781dda45b118f267 to your computer and use it in GitHub Desktop.
Save erral/4eb23da94973207e781dda45b118f267 to your computer and use it in GitHub Desktop.
#! /usr/bin/env python
# -*- coding: utf-8 -*-
""" install pdftoppm first (use your package manager) """
import os
def main(start="."):
for dirpath, dirnames, filenames in os.walk(start):
for filename in filenames:
if filename.endswith('pdf') and not filename.startswith('.') and f'{filename}.jpg' not in filenames:
os.system(f'pdftoppm -jpeg -f 1 -l 1 "{dirpath}/{filename}" > "{dirpath}/{filename}.jpg"')
print(f"Done {dirpath}/{filename}")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment