-2

is there a way to filter out all pds in a folder that have more than 30 pages like qpdf --pages *.pdf and when a documant have more than 30 pages, then extract only the first and last page and generate a new pdf with the first and last site of bevore created pdfs? thx

user3545432
  • 35
  • 1
  • 6

1 Answers1

0

According to the manual, --show-npages is used to count the pages and should output just the number. Use a for /f loop to catch it into a variable. Put another for around to process each PDF:

@echo off
for %%F in (*.pdf) do (
  for /f %%A in ('qpdf --show-npages "%%f"`) do (
    if %%A gtr 30 (
       qpdf "%%F" --pages 1,r1 -- "%%~dpnF-firstlast.%%~xF"
    )
  )
)

(completely untested, because all I know of qpdf is the manual, I just found)

Stephan
  • 53,940
  • 10
  • 58
  • 91