Scripting: attachProxy if exists

Community Beginner ,
Jun 23, 2022 Jun 23, 2022

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?

 

TOPICS
SDK

Views

49

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Employee , Jun 23, 2022 Jun 23, 2022

Hi ReginaldUser555,

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,

...

Likes

Translate

Translate
Adobe Employee ,
Jun 23, 2022 Jun 23, 2022

Copy link to clipboard

Copied

Hi ReginaldUser555,

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 13, 2022 Jul 13, 2022

Copy link to clipboard

Copied

LATEST

That works a treat, thanks Dan

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines