Page 1 of 1
Compare specific properties of two pdf files (beginner)
Posted: Thu Mar 22, 2012 9:16 am
by tkittel
Hello,
I've a flow, where incoming folders always contain two pdf files (only). In the 1st step, 'ungroup job' splits the pdf files out of their folder. In the 2nd step the modification dates of both pdfs should be compared and the prefix "top_" should be added to the newer one. The 3rd step, should move both pdf files back into their original folder using the 'assemble job' element.
What's the best way to realize step 2 ?
Thanks for help!
Thomas
Compare specific properties of two pdf files (beginner)
Posted: Thu Mar 22, 2012 5:34 pm
by dkelly
Your comparison will have to occur before the Ungroup. The two files will be in separate jobs and can't be (easily) compared.
Compare specific properties of two pdf files (beginner)
Posted: Fri Mar 23, 2012 10:11 am
by tkittel
Hello Dwight,
thanks for your info - I was afraid that it will not be easy.
Thomas
Compare specific properties of two pdf files (beginner)
Posted: Mon Mar 26, 2012 9:48 pm
by dkelly
I was able to create a script that performs the function you requested. Create a Scripted element with a single property named "prefix". Set the property to "out_" when you add Script to your flow.
function jobArrived( s : Switch, job : Job )
{
if (job.isFile()) {
job.sendToSingle(job.getPath());
} else {
var theJobDir = new Dir(job.getPath());
var theDirEntries = theJobDir.entryList("*.pdf", Dir.Files, Dir.Time);
var i;
for (i=0; i < theDirEntries.length; i++) {
var fileName = theJobDir.path + "/" + theDirEntries
;
if (i==0) {
// rename the oldest file
var theFile = new File(fileName);
var theNewName = s.getPropertyValue("prefix", job) + theFile.name;
var outFilename = job.createPathWithName(theNewName, false);
s.copy(fileName, outFilename);
job.sendToSingle(outFilename);
job.sendToNull(fileName);
} else {
job.sendToSingle(fileName);
}
}
}
}
Dwight Kelly
Apago, Inc.
dkelly@apago.com
Compare specific properties of two pdf files (beginner)
Posted: Wed Mar 28, 2012 7:00 pm
by tkittel
Hello Dwight,
today I found your code, copied it to the switch script editor and created the script element for the prefix, how you noticed it. Well, what shall I say: "It works perfectly".
So I started to adapt some details and implemented it to my flow. Now I 'only' have to analyze it to understand, how it works ;o)
Thank you very much for this code!
Have a nice day!
Thomas