Giter Club home page Giter Club logo

josee9988 / compress-pdfs Goto Github PK

View Code? Open in Web Editor NEW
12.0 2.0 3.0 47 KB

A python CLI script to π—°π—Όπ—Ίπ—½π—Ώπ—²π˜€π˜€ πŸ“¦ all the 𝗣𝗗𝗙 files π—Ώπ—²π—°π˜‚π—Ώπ˜€π—Άπ˜ƒπ—²π—Ήπ˜† in a directory using the iLovePDF technology πŸ₯°

License: GNU General Public License v3.0

Python 79.11% Shell 20.89%
compress compressor compress-files compression compressors compressed pdf pdf-files python-compressing python3

compress-pdfs's Introduction

πŸ“¦ Josee9988/Compress-PDFs

⚠️This project is not fully finished or tester, it might cause some errors with in certain situations. Please, do a backup of the folders you want to compress before using this script.⚠️


πŸ€” About the project

  • A CLI tool to compress πŸ“¦ all PDFs recursively in a directory.

⚑ Installation

  1. Clone the repository and cd into it

    git clone [email protected]:Josee9988/Compress-PDFs.git && cd Compress-PDFs
  2. Install pip3

    sudo apt install python3-pip
    # verify it with pip3 --version
  3. Instal the ilovepdf dependency

    pip3 install pylovepdf
  4. Make the script executable from anywhere

    bash MAKE_SCRIPT_GLOBAL.sh
  5. Rename .env.example to .env.

    mv -v .env.example .env # rename to .env
  6. Add your IlovePDF public key

  7. Run it ;)

    compress.py /RELATIVE/OR/ABSOLUTE/PATH/TO/YOUR/DIR/

πŸš€ Usage

  • After running the script MAKE_SCRIPT_GLOBAL.sh you can call the script from anywhere in your system with: compress.py <path>

  • The script receives only one argument and it is the path of the directory that will be recursively compressed. All the subfolders will be looked up to compress all the pdfs inside the passed directory as an argument.

  • Script profile

    compress.py <Directory path>
  • Some examples of usage

    1. Using an absolute path

      compress.py /home/username/Documents/MyFolder
    2. Using a relative path

      compress.py .
      compress.py /dirFromWhereIAm/whatever/

🌲 Project tree

.
β”œβ”€β”€ compress.py
β”œβ”€β”€ .env
β”œβ”€β”€ .github
β”‚   β”œβ”€β”€ CODE_OF_CONDUCT.md
β”‚   β”œβ”€β”€ CODEOWNERS
β”‚   β”œβ”€β”€ config.yml
β”‚   β”œβ”€β”€ CONTRIBUTING.md
β”‚   β”œβ”€β”€ FUNDING.yml
β”‚   β”œβ”€β”€ issue_label_bot.yaml
β”‚   β”œβ”€β”€ ISSUE_TEMPLATE
β”‚   β”‚   β”œβ”€β”€ 1-bug-report.md
β”‚   β”‚   β”œβ”€β”€ 2-failing-test.md
β”‚   β”‚   β”œβ”€β”€ 3-docs-bug.md
β”‚   β”‚   β”œβ”€β”€ 4-feature-request.md
β”‚   β”‚   β”œβ”€β”€ 5-enhancement-request.md
β”‚   β”‚   β”œβ”€β”€ 6-security-report.md
β”‚   β”‚   β”œβ”€β”€ 7-question-support.md
β”‚   β”‚   └── config.yml
β”‚   β”œβ”€β”€ ISSUE_TEMPLATE.md
β”‚   β”œβ”€β”€ pull_request_template.md
β”‚   β”œβ”€β”€ SECURITY.md
β”‚   β”œβ”€β”€ settings.yml
β”‚   └── SUPPORT.md
β”œβ”€β”€ .gitignore
β”œβ”€β”€ LICENSE
β”œβ”€β”€ MAKE_SCRIPT_GLOBAL.sh
└── README.md

2 directories, 25 files

πŸ“ Additional notes

  • The compressed PDF's will automatically replace your old and uncompressed ones.
  • In case an error happens because there are multiple pdfs with the same name or simply the program doesn't know how to replace them, an error will be prompt and you will have to manually move the compressed pdf (which will be in the directory passed as an argument) to the desired directory.
  • The cloned repository should not be removed as it contains the symbolic link which is globally executable. You can manually move the file and the .env file to your /bin/ folder if you wish.

Compress-PDFs was generated from Josee9988/project-template πŸ“š


πŸ•΅οΈ Extra recommendations

  • Always check the console output to check if any error happened and if so, you will have to manually move the non-moved compressed file to its location.

  • Also, always perform a copy of the folder before using the script as it will remove the old PDFs, and it might cause some data loss if an error occurs.


πŸŽ‰ Was the pdf compressor helpful? Help us raise these numbers up

Github followers Github stars Github watchers Github forks Sponsor

Enjoy! πŸ˜ƒ


βš–οΈπŸ“ License

See the license in the 'LICENSE' file.


Made with a lot of ❀️❀️ by @Josee9988

compress-pdfs's People

Contributors

josee9988 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

compress-pdfs's Issues

[Bug]

🐞 Bug Report

Doesn't work, here is the log:

Uploading file...
Traceback (most recent call last):
File "compress.py", line 51, in
task.execute()
File "/usr/local/lib/python3.8/site-packages/pylovepdf/task.py", line 169, in execute
self.upload()
File "/usr/local/lib/python3.8/site-packages/pylovepdf/task.py", line 79, in upload
file.server_filename = response.server_filename
AttributeError: 'Response' object has no attribute 'server_filename'

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.