check if file exists

Post Reply
ckuhlmann
Newbie
Posts: 12
Joined: Thu Apr 02, 2015 7:53 pm

check if file exists

Post 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
ckuhlmann
Newbie
Posts: 12
Joined: Thu Apr 02, 2015 7:53 pm

Re: check if file exists

Post 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();
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: check if file exists

Post 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.
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
Post Reply