Combining PDFs

If you need to combine a whole bunch of PDFs in a hierarchical folder, normally this will take a lot of manual steps. There are some PDF combining tools that understand folder structure such as PDFSAM, but they do not add bookmarks for each top level PDF.

Here is a method for using Powershell and PDFMerge to solve this problem.


If the filenames are already named sanely, you can just do a CTRL-F and show all the files and their subfolders, then move them into the root folder.

If the filenames are not named sanely, you can flatten the folder structure, while renaming the file names with their folder appended to the start:

ls . -r *.pdf -name -file | mi -dest {$_ -replace '\\','_'} -whatif

2. Rename Files

To rename the files, you can use PowerRename which is part of Microsoft PowerToys.

3. Add files in PDF Split And Merge

The next step is to add the files to PDFSAM and copy the filenames to the bookmarks: