I have a root folder that contains many subfolders, each with multiple PDFs. I then have a powershell script that goes through the folder structure and creates a merged PDF file (using PDFtk) for each subfolder as follows:
$pdftk = "C:\Program Files (x86)\PDFtk\bin\pdftk.exe"
$RootFolder = "path to root folder"
Get-ChildItem -r -include *.pdf | group DirectoryName | % {& $PDFtk $_.group CAT OUTPUT "$($_.Name | Split-Path -Parent)\$($_.Name | Split-Path -Leaf)_merged.pdf"}
The script works as required, however I will be working with a very large amount of data, and for that reason I need to delete the original PDFs from each folder after the merge is completed.
Basically, i need the script to look in the first folder 4830_2017, create the merged file 4830_2017_merged.pdf and then delete the PDFs located inside the 4830_2017 folder before moving on to the next folder, and doing the same thing.
I am stuggling to find the correct way of deleting the contents of each folder after the merge.
Thanks is advance for your help.