You can create a list of your PDF files that is ordered by creation date:
dir /b /tc /od *.pdf > my-pdf-filelist.txt
(If you want the list -- instead of sorted by creation time -- the sorting happing by access time use '/ta
' instead of '/tc
'; if you want ordering by modification time, use '/tw
'.)
Then use this list to create another temporary listfile, one that contains the timestamp and the PDF filenames with added dates + times on the same line:
for /f "usebackq" %i in (my-pdf-filelist.txt) ^
do (echo. %~ti %~nxi >> my-pdf-filelist.2)
Now check if your filelist my-pdf-filelist.2
does contain lines looking like this:
05/27/2009 06:08 AM fontproblems-in-footer-16_9_1557.pdf
01/20/2010 09:22 AM trainschedule-hannover.pdf
06/05/2010 07:30 PM Figure_001-a.pdf
Depending on the setting for your language+locale, your timestamp format may be different, and you may need to adapt the following step. In my case, I need to take care of the "AM/PM" thingie as well as the datestring in order to make sure the filenames will later really be in an alphabetic order that is the same as their timestamp order.
Last, use this temporary listfile to rename your original filenames so that they contain their timestamps as a prefix to their original names. But first test the intended command like this:
for /f "usebackq tokens=1,2,3,4,5,6,7 delims=/: " %i in (my-pdf-filelist.2) ^
do (echo. "%o" will be renamed to: "%k-%j-%i-%n-%l-%m-%o")
Carefully check if this would work as intended. Finally, do the real renaming:
for /f "usebackq tokens=1,2,3,4,5,6,7 delims=/: " %i in (my-pdf-filelist.2) ^
do (ren "%o" "%k-%j-%i-%n-%l-%m-%o")
Now that your PDFs are named in a way that makes 'alphabetic order' == 'timestamp order' you can simply run pdftk.exe
:
pdftk.exe *.pdf cat output merged.pdf