Last active
February 1, 2025 12:03
-
-
Save lumenpink/0d786303e2c7f967b336f106b60ec67c to your computer and use it in GitHub Desktop.
Extract each page from pdf files in the current directory in a sigle file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script will extract each page from pdf files in the current directory in a sigle file | |
# | |
# MIT License | |
# Copyright (c) 2025 Lumen Freitas <[email protected]> | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files. | |
I=1 | |
find . -name \*.pdf | | |
while read -r FILE; do | |
echo "Processing $FILE" | |
PAGES=$(pdftk "$FILE" dump_data | grep NumberOfPages | awk '{print $2}') | |
echo "Found $PAGES pages" | |
for ((i = 1; i <= PAGES; i++)); do | |
echo "Extracting page $i (FILE-$I)" | |
pdftk "$FILE" cat "$i" output PDF/file-"$I".pdf | |
I=$((I + 1)) | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment