Page 1 of 1

check if file exists

Posted: Thu Feb 11, 2016 3:44 am
by ckuhlmann
Hello All,

Is it possible to check if a file exists in a repository before injecting it.

I have a hold node that I want to be conditionally released to the inject file node if the specific file to inject is available.

Thanks

Re: check if file exists

Posted: Fri Feb 12, 2016 12:06 am
by ckuhlmann
Figured it out:

function getFileStatus() : string {

var fPath = full path to file including file name';

var fa = new File(fPath);

if ( fa.exists ){
return true;
}
else{
return false;
}
}
getFileStatus();

Re: check if file exists

Posted: Sun Feb 14, 2016 4:57 pm
by gabrielp
Thanks for sharing your solution. I think you could also do this with two injects if you didn't have the scripting module. One to inject the file as a copy leaving the original in place, the second to run it into whatever use case you wanted to use the original inject for. If the first inject failed, you could assume the file doesn't exist.