It would be useful to be able to populate the initial file list with a set of filenames
Obviously passing a single name would be a minimum for say splitting but it gets more complicated to specify ranges etc
I suggest a plain text file could initially be used to preload the first tab
c:\path\filename.pdf
d:\path\second file.pdf
optionally without making it too complicated for page ranges etc
If you need a free GUI PDF merge tool that directly supports loading PDF documents from a list (.txt file), I recommend you consider PDFsam Basic (pdfsam.org). It does exactly what you are asking for, even allowing the user to drag the .txt file containing the file list directly onto the window of its merge tool.
The ability to accept an external list of files seems to be rare among PDF applications. To support reloading documents, most applications appear to favor internally generated recently used documents lists, lists of prior sessions, or recently used source document folders. Using a list rather than interactively selecting the files raises the possibility that a file in the list may been misspelled or may have been deleted, renamed, or moved in the interim. I noticed that when PDFsam Basic processes a list containing a file it cannot find, it skips the file but provides no warning to the user that it did so and that the skipped file will therefore be missing from the merged output PDF. Importing page ranges from an external list would be even more problematic.
I have been able to use a list of files (indirectly) with PDFtk Builder by first running a PowerShell script to copy the PDF files in the list to a destination folder and adding a sequence number prefix to the file names. The PDF files in the destination folder can then be selected all at once and dragged and dropped onto the PDFtk Builder "Join Files' window with the sequence numbers ensuring the original file order in the list is preserved. However, not all users may be able to run a PowerShell script and I suspect the amount of use of a file list option would not warrant its incorporation programmatically into PDFtk Builder.
PDFsam Basic is a Java app (requires JRE) using a much more recent PDF engine than the one underlying PDFtk and performs merge tasks noticeably quicker than PDFtk Builder. However, for the occasional user, its user interface and available options seem overly complex.
If you download PDFsam Basic from pdfsam.org using their Windows downloader, please note that there is an option to uncheck the offer to also install the trial version of PDFsam Enhanced, which is a completely different program, not an enhanced version of PDFsam Basic.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for the suggestion to use PDFsam, however I am always avoiding Java coded applications.
I can drag and drop a group of files into SumatraPDF TOC editor to generate a merged PDF, albeit the output currently drops any bookmarks (one usage for pdftk-builder-enhanced) I will look into your suggestion to renumber the files. Thanks
Attached below is a copy of copyfiles.ps1, a Windows PowerShell script that I wrote to copy a list of files to a common destination directory with a 2-digit sequence number prefix added to each file name to maintain file order. This script can be used to populate the 'Join Files' window of PDFtk Builder Enhanced and any other PDF merge tool that supports drag and drop, with files from a list. The following are instructions on how to set up the script and use it.
copyfiles.ps1: Copy the text of PowerShell script below and save it in a file named copyfiles.ps1.
copyfiles.bat: Also copy the following text of the following three-line batch file to run the script in a text file named copyfiles.bat.
copyfiles-list.txt: Create your list of .pdf files (full file name including path and ext without quotes) and save it in a text file named copyfiles-list.txt. Note: To capture the text for the full path of an individual file in Windows Explorer, select the file, shift right click, and select the Copy as Path option which will copy the full path to the clipboard. Then paste the copied text into a new line of the list file. Delete the beginning and ending quotation marks.
Place the three files (copyfiles.ps1, .bat, .txt) in a folder of your choice. I suggest using the same folder where PDFtk Builder Enhanced is located. The script will also write a log file (copyfiles-log.txt) to the same folder each time it is run. If the script did not encounter any files not found, the list file and log file should be identical; however, if a file specified in the list cannot be found on the system, the file not found error will be indicated in the log file.
To run the script: Simply double-click on the copyfiles.bat file. The script can also be executed separately by right-clicking on the copyfile.ps1 and selecting "Run with PowerShell". (This step assumes user and system are configured to be able to run a PS script)
Destination folder: The files specified in the list will be copied to the destination folder %TEMP%/copyfiles, which would typically be C:\users\<username>\AppData\Local\Temp\copyfiles. The script creates the copyfiles destination folder if it does exist. Each time it is run, it deletes any .pdf files that had been left in the folder before copying the new set of files to the folder.</username>
Inputting the files to PDFtk Builder: The copyfiles.bat folder will automatically open the destination folder when the script completes. Select all the copied files (ctrl-A) and drag and drop them onto PDFtk Builder's 'Join Files' window. If the drag point where you grabbed the selected files was not on the first file (01-<filename>.pdf), click on "Sort" button in PDFtk Builder to restore the original sequence of the files in the list. </filename>
Notes:
a. The copyfiles.bat file can be launched from within PDFtk Builder (Tool Set 4 - Launch) by including an entry for an external PDF app in the PDftkBuuilder.ini file like the following:
In the above example, the files for copyfiles (.bat, .ps1 and .txt) are located in a same folder housing the files for PDFtk Builder.
b. The # at the start of a line in the PowerShell script below denotes a comment. The script was tested on Windows 10 Pro (x64), version 1909.
c. Regarding your mention of the TOC Editor in the SumatraPDF pre-release, PDFTK v2.02 which is used by PDFtk Builder Enhanced preserves bookmarks (PDF outlines) when merging full files; PDFTK versions before 2.00 do not. I tried using PDFTK Builder Enhanced to merge multiple PDF files specified in a list and gathered by the copyfiles script as described above and the files were successfully merged and the bookmarks worked in the combined PDF. However, since PDFTK represents bookmarks by level, title and goto page number only, an action such as scrolling to a specific location on a page will become only a goto page number in the merged PDF.
I must admit I like the basic premise of the suggestion, but in deference to it not being taken up can I ask something rather simple, that PDFTK could if possible just detect a single file in the command-line startup and open it in Join mode. This would allow the program to be invoked from SumatraPDF as a custom menu item to open the currently-viewing file for extracting pages, or be invoked from explorer on some selected file. It's a bit cumbersome to do without it, and like the original author I tend to avoid Java-y things!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It would be useful to be able to populate the initial file list with a set of filenames
Obviously passing a single name would be a minimum for say splitting but it gets more complicated to specify ranges etc
I suggest a plain text file could initially be used to preload the first tab
c:\path\filename.pdf
d:\path\second file.pdf
optionally without making it too complicated for page ranges etc
Actions.txt
PDFIN c:\path\filename.pdf
PDFFILE2 d:\path\second file.pdf
PDFOUT e:\path\outfile.pdf
If you need a free GUI PDF merge tool that directly supports loading PDF documents from a list (.txt file), I recommend you consider PDFsam Basic (pdfsam.org). It does exactly what you are asking for, even allowing the user to drag the .txt file containing the file list directly onto the window of its merge tool.
The ability to accept an external list of files seems to be rare among PDF applications. To support reloading documents, most applications appear to favor internally generated recently used documents lists, lists of prior sessions, or recently used source document folders. Using a list rather than interactively selecting the files raises the possibility that a file in the list may been misspelled or may have been deleted, renamed, or moved in the interim. I noticed that when PDFsam Basic processes a list containing a file it cannot find, it skips the file but provides no warning to the user that it did so and that the skipped file will therefore be missing from the merged output PDF. Importing page ranges from an external list would be even more problematic.
I have been able to use a list of files (indirectly) with PDFtk Builder by first running a PowerShell script to copy the PDF files in the list to a destination folder and adding a sequence number prefix to the file names. The PDF files in the destination folder can then be selected all at once and dragged and dropped onto the PDFtk Builder "Join Files' window with the sequence numbers ensuring the original file order in the list is preserved. However, not all users may be able to run a PowerShell script and I suspect the amount of use of a file list option would not warrant its incorporation programmatically into PDFtk Builder.
PDFsam Basic is a Java app (requires JRE) using a much more recent PDF engine than the one underlying PDFtk and performs merge tasks noticeably quicker than PDFtk Builder. However, for the occasional user, its user interface and available options seem overly complex.
If you download PDFsam Basic from pdfsam.org using their Windows downloader, please note that there is an option to uncheck the offer to also install the trial version of PDFsam Enhanced, which is a completely different program, not an enhanced version of PDFsam Basic.
Command Line / file list
Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/pdftk-builder-enhanced/discussion/general/
Attached below is a copy of copyfiles.ps1, a Windows PowerShell script that I wrote to copy a list of files to a common destination directory with a 2-digit sequence number prefix added to each file name to maintain file order. This script can be used to populate the 'Join Files' window of PDFtk Builder Enhanced and any other PDF merge tool that supports drag and drop, with files from a list. The following are instructions on how to set up the script and use it.
copyfiles.ps1: Copy the text of PowerShell script below and save it in a file named copyfiles.ps1.
copyfiles.bat: Also copy the following text of the following three-line batch file to run the script in a text file named copyfiles.bat.
copyfiles-list.txt: Create your list of .pdf files (full file name including path and ext without quotes) and save it in a text file named copyfiles-list.txt. Note: To capture the text for the full path of an individual file in Windows Explorer, select the file, shift right click, and select the Copy as Path option which will copy the full path to the clipboard. Then paste the copied text into a new line of the list file. Delete the beginning and ending quotation marks.
Place the three files (copyfiles.ps1, .bat, .txt) in a folder of your choice. I suggest using the same folder where PDFtk Builder Enhanced is located. The script will also write a log file (copyfiles-log.txt) to the same folder each time it is run. If the script did not encounter any files not found, the list file and log file should be identical; however, if a file specified in the list cannot be found on the system, the file not found error will be indicated in the log file.
To run the script: Simply double-click on the copyfiles.bat file. The script can also be executed separately by right-clicking on the copyfile.ps1 and selecting "Run with PowerShell". (This step assumes user and system are configured to be able to run a PS script)
Destination folder: The files specified in the list will be copied to the destination folder %TEMP%/copyfiles, which would typically be C:\users\<username>\AppData\Local\Temp\copyfiles. The script creates the copyfiles destination folder if it does exist. Each time it is run, it deletes any .pdf files that had been left in the folder before copying the new set of files to the folder.</username>
Inputting the files to PDFtk Builder: The copyfiles.bat folder will automatically open the destination folder when the script completes. Select all the copied files (ctrl-A) and drag and drop them onto PDFtk Builder's 'Join Files' window. If the drag point where you grabbed the selected files was not on the first file (01-<filename>.pdf), click on "Sort" button in PDFtk Builder to restore the original sequence of the files in the list. </filename>
Notes:
a. The copyfiles.bat file can be launched from within PDFtk Builder (Tool Set 4 - Launch) by including an entry for an external PDF app in the PDftkBuuilder.ini file like the following:
In the above example, the files for copyfiles (.bat, .ps1 and .txt) are located in a same folder housing the files for PDFtk Builder.
b. The # at the start of a line in the PowerShell script below denotes a comment. The script was tested on Windows 10 Pro (x64), version 1909.
c. Regarding your mention of the TOC Editor in the SumatraPDF pre-release, PDFTK v2.02 which is used by PDFtk Builder Enhanced preserves bookmarks (PDF outlines) when merging full files; PDFTK versions before 2.00 do not. I tried using PDFTK Builder Enhanced to merge multiple PDF files specified in a list and gathered by the copyfiles script as described above and the files were successfully merged and the bookmarks worked in the combined PDF. However, since PDFTK represents bookmarks by level, title and goto page number only, an action such as scrolling to a specific location on a page will become only a goto page number in the merged PDF.
--
--
Text file copyfiles.ps1 attached
Last edit: David King 2020-04-21
I must admit I like the basic premise of the suggestion, but in deference to it not being taken up can I ask something rather simple, that PDFTK could if possible just detect a single file in the command-line startup and open it in Join mode. This would allow the program to be invoked from SumatraPDF as a custom menu item to open the currently-viewing file for extracting pages, or be invoked from explorer on some selected file. It's a bit cumbersome to do without it, and like the original author I tend to avoid Java-y things!