How to Automatically Create PDF Bookmarks from Folders and Subfolders
Question details
The user wants to automatically generate a hierarchical bookmark tree in a PDF based on the directory structure of files, folders, and subfolders stored in a root folder.

- Product
- PDF Software
- Device & OS
- not provided
- Scenario
- Organizing a large directory of documents into a single indexed PDF system without manually creating and nesting bookmarks.
- Observed behavior
- Native software features often ignore folder hierarchies, only creating bookmarks for individual files when merging, or result in excessively large files that crash the system.
Gather all your target PDF files into a single root directory and ensure the folders and files are clearly named, as automation scripts will use these names to generate your bookmark text.
Use Custom JavaScript and Actions in Acrobat Pro
Since there is no built-in one-click feature for folder-to-bookmark conversion, you must use a custom script within Adobe Acrobat Pro to read the directory structure.
Standard PDF editors do not have a native feature to mirror your operating system's folder hierarchy as bookmarks. To achieve this, you need an external script or an Action that iteratively reads your root directory, creates bookmarks for each folder, and links to the contained PDFs.
Open your premium PDF software (like Adobe Acrobat Pro) and navigate to the Action Wizard tool in the tools menu.
Click on 'New Action' and insert an 'Execute JavaScript' step into the action sequence.
Paste a custom folder-parsing JavaScript (usually obtained from specialized PDF developer forums) designed to scan directories and generate bookmark trees.
Execute the Action on your target root folder. The script will automatically generate the hierarchical bookmark tree based on the folder structure.

Combine Files and Auto-Bookmark by Filename
If custom scripting is too complex, you can merge the files using a PDF editor that automatically sets file names as bookmarks, though you will need to nest the folders manually.
Easily Merge Documents and Manage Bookmarks in WPS Office
While mapping complex OS folder structures requires custom scripts, WPS PDF provides an intuitive, lightweight way to combine multiple files into one PDF and automatically use file names as bookmarks, avoiding system crashes.
- 1. Launch WPS PDF: Open WPS Office and navigate to the dedicated PDF toolkit.
- 2. Select Merge PDF: Click on 'Merge PDF' from the main dashboard or tools menu.
- 3. Add Your Files: Import all the PDF files you want to combine from your various folders.
- 4. Configure Bookmark Settings: Ensure you check the option to generate bookmarks from the merged file names before proceeding.
- 5. Combine and Nest: Click 'Merge'. Afterward, use the left-hand navigation pane to drag and nest bookmarks to represent your folder tree.

Frequently Asked Questions
Can standard PDF software automatically create bookmarks from my Windows folders?
No, most PDF software natively creates bookmarks based on document text headings or merged file names. Reading a computer's folder and subfolder directory structure to create a PDF index requires custom JavaScript or automation scripts.
Why does my computer lock up when combining many PDFs?
Merging hundreds of PDFs from various subfolders creates a massive file size that consumes significant RAM and CPU. It is recommended to compress the files beforehand, merge them in smaller batches, or link them via external bookmarks instead of merging.
How do I manually create a sub-bookmark in a PDF?
Open the bookmark panel in your PDF editor, select the bookmark you want to demote, and drag it slightly to the right under a parent bookmark. It will automatically nest as a sub-bookmark, creating a hierarchical tree.
Is it possible to link multiple separate PDFs via bookmarks instead of merging them?
Yes. You can create a master PDF index file and set the action for each bookmark to 'Open a file' rather than navigating to a page within the same document. This method keeps individual file sizes small and prevents system lag.




