Git Product home page Git Product logo

sort_files's Introduction

PDF File Sorting Script

This quickly hacked Python script organizes all PDFs in a given directory by parsing their content. It moves each file into a directory named after the first author (formatted as "Lastname Surname") and renames the file in the format "year title.pdf".

Features

  • Content Parsing: Extracts metadata like author names, publication year, and title from PDF files.
  • File Organization: Moves PDFs into author-named directories and renames them based on year and title.
  • OCR Capability: Performs on-the-fly OCR as needed using pytesseract.

Requirements

  • Python: Ensure Python is installed on your system.
  • Python Libraries: Requires specific libraries which can be installed via pip:
    pip install PyPDF2 pdf2image pytesseract tqdm openai
  • System Dependencies:
    • Poppler and Tesseract: Necessary for PDF to image conversion and OCR functionality.
      sudo apt-get install poppler-utils tesseract-ocr tesseract-ocr-eng
  • Ollama Setup:
    • Model Installation: The script uses a local Ollama instance with a specific LLM model. The default is cas/spaetzle-v58, suitable for English and German text. Change the model as per your requirements.
      ollama pull cas/spaetzle-v58

Usage

Run the script in the directory containing the PDFs you want to sort:

python parse_pdfs.py ./

This command sorts all PDFs in the current directory. Customize the script's model or configurations as necessary to fit your specific needs.

sort_files's People

Contributors

crispstrobe avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.