Hello,
I'm struggling with a (for me at least) rather complicated workflow.
The input files are in a folder. Basically this folder can include any file (PDF, AI, JPEG,...), but I only want to use the job.jdml and output.pdf files.
If there isn't an output.pdf AND a job.jdml file in this input folder, I want to delete this folder completely.
Thanks for any help.
checking for mandatory filenames, or delete everything
-
- Newbie
- Posts: 1
- Joined: Wed Feb 15, 2012 10:12 pm
-
- TOP CONTRIBUTOR
- Posts: 628
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
checking for mandatory filenames, or delete everything
function jobArrived( s : Switch, job : Job )
{
var dir = new Dir(job.getPath());
var entries = dir.entryList("*", Dir.Files, Dir.Name);
var requiredFiles = 0;
for (var i=0; i<entries.length; i++) {
var fn = entries;
if (fn == "output.pdf" || fn == "job.jdml")
requiredFiles++;
}
if (requiredFiles == 2)
job.sendToSingle(job.getPath());
job.sendToNull(job.getPath());
}
{
var dir = new Dir(job.getPath());
var entries = dir.entryList("*", Dir.Files, Dir.Name);
var requiredFiles = 0;
for (var i=0; i<entries.length; i++) {
var fn = entries;
if (fn == "output.pdf" || fn == "job.jdml")
requiredFiles++;
}
if (requiredFiles == 2)
job.sendToSingle(job.getPath());
job.sendToNull(job.getPath());
}
checking for mandatory filenames, or delete everything
Dwight, this is not on purpose. I was just going to post what follows and saw that you had already answered
. I am posting anyhow.
Freddy
----------------------
It is not that difficult to solve this with a script, but here is a way you can do this without one (fine-tuning required).
Ungroup the incoming job. This will get all the files out of the folder as separate jobs and tag them as belonging together. Then you add Assembly job. This will put everything into a folder again, but you put a condition on the connection to only let through the files that you want (probably using file patterns). You also have to use Scheme - Ungrouped job and Number of files: 2. If all is well you will get a folder with your two files in it in the Success folder. If you only have one file it will not get assembled, so it is also best to set the timeout to the smallest possible value.
If you could potentially have three or more files that did not end up in the Recycle bin, then I suggest a slightly different approach. Set the Number of files in the Assemble job to Automatic. This means your files will only get successfully assembled (i.e. without a wait time) when there were only the correct two files in the incoming folder. In all other cases Switch waits for a timeout and assembles the job and then you use a condition with the variable [Job.FileCount] to check whether that value is 2 or not.

Freddy
----------------------
It is not that difficult to solve this with a script, but here is a way you can do this without one (fine-tuning required).
Ungroup the incoming job. This will get all the files out of the folder as separate jobs and tag them as belonging together. Then you add Assembly job. This will put everything into a folder again, but you put a condition on the connection to only let through the files that you want (probably using file patterns). You also have to use Scheme - Ungrouped job and Number of files: 2. If all is well you will get a folder with your two files in it in the Success folder. If you only have one file it will not get assembled, so it is also best to set the timeout to the smallest possible value.
If you could potentially have three or more files that did not end up in the Recycle bin, then I suggest a slightly different approach. Set the Number of files in the Assemble job to Automatic. This means your files will only get successfully assembled (i.e. without a wait time) when there were only the correct two files in the incoming folder. In all other cases Switch waits for a timeout and assembles the job and then you use a condition with the variable [Job.FileCount] to check whether that value is 2 or not.