feat: improved pdf page count script

This commit is contained in:
2026-07-26 14:47:18 +02:00
parent ecaab3e673
commit 08c3d41ff2
+13 -9
View File
@@ -1,16 +1,20 @@
#!/bin/sh #!/bin/sh
if [[ -n $1 ]]; then if [[ -n $1 ]]; then
echo "File contains $(pdfinfo $1 | awk '/^Pages:/ {print $2}') pages" echo "File contains $(pdfinfo $1 | awk '/^Pages:/ {print $2}') pages"
else else
total=0 total=0
for file in *.pdf; do count=0
count=$(pdfinfo $file | awk '/^Pages:/ {print $2}') for file in *.pdf; do
echo "$count pages in $file" count_file=$(pdfinfo $file | awk '/^Pages:/ {print $2}')
total=$(($total + count)) echo "$count_file pages in $file"
done total=$(($total + count_file))
count=$((count + 1))
done
echo " echo "
Total page count is $total -> Total page count: $total
-> Total files: $count
-> Median: $(($total / $count))
" "
fi fi