Copy link to clipboard
Copied
Is there a way to check if a file exists before using attachProxy() ?
This is my workaround:
if (app.sourceMonitor.openFilePath(proxyFileURL)){
pItem.attachProxy(proxyFileURL,0);
}
It works well, but I was wondering if there was a cleaner way?
Great question. File Object might help you, it's documented here:
https://extendscript.docsforadobe.dev/file-system-access/file-object.html#file-object
so, for example, if you have a file named blahblah.prproj on your desktop;
var myProj = new File('/Users/<myusername>/Desktop/blahblah.prproj');
if (myProj){
if (myProj.exists){
alert("Yay, " + myProj.fsName + " exists!");
} else {
alert("Boo, " + myProj.fsName + " does not exist!");
}
}
Thanks for contributing to forums,
Copy link to clipboard
Copied
Great question. File Object might help you, it's documented here:
https://extendscript.docsforadobe.dev/file-system-access/file-object.html#file-object
so, for example, if you have a file named blahblah.prproj on your desktop;
var myProj = new File('/Users/<myusername>/Desktop/blahblah.prproj');
if (myProj){
if (myProj.exists){
alert("Yay, " + myProj.fsName + " exists!");
} else {
alert("Boo, " + myProj.fsName + " does not exist!");
}
}
Thanks for contributing to forums,
-Dan
Copy link to clipboard
Copied
That works a treat, thanks Dan