Testing to see if a folder exists in a location

Post Reply
PaulHough
Newbie
Posts: 13
Joined: Thu Jan 31, 2013 5:23 pm

Testing to see if a folder exists in a location

Post by PaulHough »

I have a flow that will reach out and grab a folder from a location and injects it into a flow via metadata.



What i need is;



if (folder exists){current code}

else {send email}.



I have tried the job.getFileCount() but I couldn't retrieve a value with a location path.



Any suggestions would be helpful.



Thanks,

PH







function jobArrived( s : Switch, job : Job )

{

var JobNumber = job.getVariableAsString('[Metadata.Text:Path="/field-list/field[2]/field-list/field/value",Dataset="Submit",Model="XML"]');

var theSourcePath = job.createPathWithName( JobNumber );





s.copy( "/Users/prinergy/Desktop/Fake jobs/"+JobNumber, theSourcePath );

job.sendToSingle( theSourcePath );

job.sendToNull( job.getPath() );



s.log(1,JobNumber);

}




dkelly
TOP CONTRIBUTOR
Posts: 628
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Testing to see if a folder exists in a location

Post by dkelly »

You can't send an email directly from a script. You will have to set the email variables and send it using an Email Send element in you flow.



function jobArrived( s : Switch, job : Job )

{

var JobNumber = job.getVariableAsString('[Metadata.Text:Path="/field-list/field[2]/field-list/field/value",Dataset="Submit",Model="XML"]');

var theSourcePath = job.createPathWithName( JobNumber );



var folderName = "/Users/prinergy/Desktop/Fake jobs/"+JobNumber;

if (File.exists(folderName)) {

s.copy( folderName, theSourcePath );

job.sendToSingle( theSourcePath );

job.sendToNull( job.getPath() );



s.log(1,JobNumber);

} else {

s.log(1,"Folder " + folderName + " does not exist");

}

}
PaulHough
Newbie
Posts: 13
Joined: Thu Jan 31, 2013 5:23 pm

Testing to see if a folder exists in a location

Post by PaulHough »

Do i have to declare File as a Var?



Thanks,

PH
dkelly
TOP CONTRIBUTOR
Posts: 628
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Testing to see if a folder exists in a location

Post by dkelly »

no, because File.exists() is a static function.
PaulHough
Newbie
Posts: 13
Joined: Thu Jan 31, 2013 5:23 pm

Testing to see if a folder exists in a location

Post by PaulHough »

Is there a site that lists all of the static function?



Thanks,

Paul hough
dkelly
TOP CONTRIBUTOR
Posts: 628
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Testing to see if a folder exists in a location

Post by dkelly »

No, you have to review the Javascript documentation for each class. It will list the static functions.



http://www.enfocus.com/Manuals/UserGuid ... S/home.htm
PaulHough
Newbie
Posts: 13
Joined: Thu Jan 31, 2013 5:23 pm

Testing to see if a folder exists in a location

Post by PaulHough »

Thanks for your help



PH


Post Reply