Page 1 of 1

FInding what is MISSING in a sequential series

Posted: Wed Jan 04, 2012 1:05 am
by CGXTex
Hi all,



Thank you for you help ahead of time. I am looking for a way to figure out what is missing in a sequential series of pdfs.



I am receiving pdf files named 01.pdf, 02.pdf, 03.pdf and so on and so forth. I know how many files I need to complete the job, but there will be files missing which I will need to inject a blank page.



So, I know i have a 16 pg job but I only receive 14 files because 02.pdf and 15.pdf are missing (inside pages of a cover).



How can I identify pg 2 and 15 are missing so I can use 'Inject Job' to input a blank '02.pdf' and '15.pdf' file from a repository of files that I have created. I know the file sizes before hand so I can create these blank files before hand.



I guess I am having trouble trying to initiate in action that has no trigger because it does not exist. The missing files are not always going to be 2 and 15 also.



I have some ideas in mind that I know will work, but it would be like putting duct tape on a leaky dam.



Thanks,



Dave Tecson

dtecson@cgx.com

281-723-3540

FInding what is MISSING in a sequential series

Posted: Wed Jan 04, 2012 9:02 am
by bert_vr
CGXTex,



This will not be possible with the out-of-the box features of Switch.



What you would need is a script expression (PowerSwitch only) that will scan the range e.g. 1-16, find the ones missing and route them to e.g. Acrobat that will allow you to add 2 empty pages for those that are missing.



you might want to send this request to professionalservices@enfocus.com.



cheers,

Bert

FInding what is MISSING in a sequential series

Posted: Wed Jan 04, 2012 5:08 pm
by dkelly
As Bert stated, you will need a custom script that takes a variable with the number of expected files. The script would enumerate all of the files in the job and detect those that were missing. The format of the file name would have to be consistent or you could pass in the filename format as a property, eg. Mag_%2d.pdf, if the script supported this functionality.



Happy New Year!

Dwight Kelly

Apago, Inc.

dkelly@apago.com

FInding what is MISSING in a sequential series

Posted: Thu Jan 05, 2012 3:58 pm
by CGXTex
Thanks for your replies! I suspected as much, but I just needed confirmation that I was not overlooking the standard options within Switch.

FInding what is MISSING in a sequential series

Posted: Tue Jan 17, 2012 8:51 pm
by dkelly
Dave,



Here's Javacript that will detect missing files. It assumes the filenames have 2 digits, eg 01.pdf, 02.pdf, etc.



var dirObj = new Dir(job.getPath());

var dirEntries = dirObj.entryList( "*.pdf", Dir.Files, Dir.Name );

var pagesArray = new Array();

var i;

for (i=0; i<dirEntries.length; i++) {

job.log(1, dirEntries);

var pg = dirEntries.substring(0,2);

pagesArray.push(pg);

}

pagesArray.sort();

for (i=0; i<pagesArray.length-1; i++) {

var nextPg = parseInt(pagesArray,10)+1;

if (parseInt(pagesArray[i+1],10) != nextPg)

job.log(1, "Missing page " + nextPg);

}





Dwight Kelly

Apago, Inc.

dkelly@apago.com