Link to home
Start Free TrialLog in
Avatar of E=mc2
E=mc2Flag for Canada

asked on

Join several pdf files based on time stamp

Using pdftk what command can I use to join files, first in the order of the file that was created first?

For example, let's say in the path C:\Attachment, there are 4 file all with different names, however all with different time stamps...

How can I modify this command so that it joins each file it finds but based on time stamp? all into 1 file?

pushd "C:\Users\Desktop\Folder"
pdftk ….. cat output C:\Attachment\OneFile.pdf
popd
Avatar of Bill Prew
Bill Prew

This should do what you requested.

@echo off
setlocal EnableDelayedExpansion

set BaseDir=c:\attachment
set MergeFile=c:\attachment\OneFile.pdf
set MergeList=

for /f "tokens=*" %%A in ('dir /b /a-d /od /tc "%BaseDir%\*.pdf"') do (
    set MergeList=!MergeList! "%BaseDir%\%%~A"
)

pdftk %MergeList% cat output "%MergeFile%"

Open in new window


»bp
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.