- A CLI tool to compress π¦ all PDFs recursively in a directory.
-
Clone the repository and
cd
into itgit clone git@github.com:Josee9988/Compress-PDFs.git && cd Compress-PDFs
-
Install pip3
sudo apt install python3-pip # verify it with pip3 --version
-
Instal the ilovepdf dependency
pip3 install pylovepdf
-
Make the script executable from anywhere
bash MAKE_SCRIPT_GLOBAL.sh
-
Rename
.env.example
to.env
.mv -v .env.example .env # rename to .env
-
Add your IlovePDF public key
- Modify the
.env
file add update thePUBLIC_KEY
variable with your public key from the IlovePDF developer's site
- Modify the
-
Run it ;)
compress.py /RELATIVE/OR/ABSOLUTE/PATH/TO/YOUR/DIR/
-
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
-
Using an absolute path
compress.py /home/username/Documents/MyFolder
-
Using a relative path
compress.py .
compress.py /dirFromWhereIAm/whatever/
-
.
βββ 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
- 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 π
-
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.
Enjoy! π
See the license in the 'LICENSE' file.
Made with a lot of β€οΈβ€οΈ by @Josee9988