Search code examples
windowspowershellpdfghostscriptpdftk

PDFTK Script to split all files within a folder - noob


Want a script to run and split all files in a folder to 1 page PDF documents then move them to another folder. I'm on windows and I'm a noob and need some assistance. The below code works but I cannot wildcard all PDF files. Get-ChildItem -File | Foreach {c:\test*.PDF} doesn't work with PDFTK?

The below script works

cmd /c "for %s in (c:\test*.pdf) do pdftk %s burst output c:\pdftest\%~ns_%02d.pdf"


Solution

  • Looking at this again, I can't see any reason why you can't do this with simple shell programming. Something like:

    for %s in (c:\test*.pdf) do pdftk %s burst output c:\pdftest\%~ns_%02d.pdf

    ought to work.