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. NOTE: If files are not showing in search, the indexer might be trying to do file content indexing (instead of just the filenames). You can disable file content indexing like this: Open File Explorer > Right-click on your hard drive (Usually C), and click Properties. > Check or uncheck the box next to Allow files on this drive to have contents indexed in addition to file properties.
Click on OK.
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:
Start Powershell.
Change directory (cd) to the folder with all the files.
Enter the following command to test the move:
ls . -r *.pdf -name -file | mi -dest {$_ -replace '\\','_'} -whatif
When you are happy with this, remove "-whatif" from the end to execute the command.
To rename the files, you can use PowerRename which is part of Microsoft PowerToys.
The next step is to add the files to PDFSAM and copy the filenames to the bookmarks: