I am trying to combine pdfs based on filename (IMG_2.pdf) with all pdfs located in a subfolder that has the same name as the pdf with padding (IMG_2.pdfX).
Subfolder can have additional subfolders (like 22.pdfX) named after pdf in the first subfolder (22.pdfX) and has additional pdfs (like IMGk.pdf).
C:.
│ IMG_2.pdf
├───IMG_2.pdfX
│ │ 22.pdf
│ └───22.pdfX⠀
│ IMGk.pdf
This shows tree for one pdf and its subfolder, there are hundreds of PDF in with such structure.
Output should be one pdf for IMG_2.pdf, that combines all other pdf into this or new file, and so on for all other pdf in source directory (pdf).
Tried pdftk but got stuck. Any solution on linux or windows is welcome, windows is preferable.