DonationCoder.com Software > Finished Programs
DONE: Using AHK and PDFTK to combine daily pdf's
(1/1)
schnarkle:
Hello,
I need to come up with a way of combining daily extracted pdfs in the proper order but am having problems with the number of different publications.
Our naming convention is :
pub date section
--------------------
MM_111412_A01.pdf
MM_111412_A02.pdf
MM_111412_B01.pdf
MC_111412_A01.pdf
WR_111412_A01.pdf
I can do this for one pub easily i.e.
--- Code: Autohotkey ---SetWorkingDir, %A_ScriptDir%pub = MM dest = D:\DATA\archives\hot\formattime, date, MMddyy, MMddyy filename1 = %pub%_%date%_*.pdf ifexist %filename1%Runwait %comspec% /c pdftk %filename1% cat output %dest%EA_%date%.pdf
But with 7 different pubs, some of which may or may not appear on a daily basis, I am stuck.
Here's what I came up with but it is not getting every pub and some pages are repeating. I am trying but am an amateur N00B :)
Also, the pub order is as seen top to bottom.
--- Code: Autohotkey ---SetWorkingDir, %A_ScriptDir%pub = MMpub2 = MCpub3 = FEpub4 = CSpub5 = REpub6 = VLpub7 = WR dest = D:\DATA\archives\hot\formattime, date, MMddyy, MMddyy filename1 = %pub%_%date%_*.pdffilename2 = %pub2%_%date%_*.pdffilename3 = %pub3%_%date%_*.pdffilename4 = %pub4%_%date%_*.pdffilename5 = %pub5%_%date%_*.pdffilename6 = %pub6%_%date%_*.pdffilename7 = %pub7%_%date%_*.pdf FileList = Loop, *_%date%_*.pdf{ FileList = %FileList%%A_LoopFileName%`n Runwait %comspec% /c pdftk %filename1% %A_LoopFileName% cat output MTR_%date%.pdf }Can anyone help?
Target:
I assume you're trying to do this in AHK?
you need 2 nested loops, something like this
--- ---pub = MM,MC,FE,CS,RE,VL,WR
loop, parse, pub, CSV
{
Loop, %a_loopfield%_%date%_*.pdf
Runwait %comspec% /c pdftk %filename1% %A_LoopFileName% cat output MTR_%date%.pdf
}
skwire:
You can pass multiple PDF filenames at one time to pdftk. This should work:
--- Code: Autohotkey ---; Environment.SetWorkingDir, % A_ScriptDir ; Variables.FormatTime, myDate, A_Now, MMddyy ; Format today's date.myPubOrder := "MM,MC,FE,CS,RE,VL,WR" ; Maintain publication order as per request.Loop, Parse, myPubOrder, `,{ ; Create a space-delimited list of PDF filenames. Loop, % A_LoopField . "_" . myDate . "_*.pdf" { myString .= A_LoopFileName . " " }}; Pass full list of PDFs to pdftk and output to new file.RunWait %comspec% /c pdftk.exe %myString% cat output MTR_%myDate%.pdf
schnarkle:
Good grief you guys make it look so easy!
Thank you so much that was driving me nuts!
:Thmbsup:
skwire:
Good grief you guys make it look so easy!
Thank you so much that was driving me nuts!-schnarkle (November 15, 2012, 10:36 AM)
--- End quote ---
You're very welcome. I'm glad we were able to help out. :) I'm going to mark this thread as done and move it.
Navigation
[0] Message Index
Go to full version