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)
-
dkelly
- TOP CONTRIBUTOR
- Posts: 628
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
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
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
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
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