Copy link to clipboard
Copied
My script works to replace a file in my bin.
I highlight multiple AVItems in my bin, get the naming convention, and replace them with new files from a specified directory. Works, all good.
My issue now is i want an alert if the file im trying to import is not in the directory.
so in my code i have this snippet. I think my idea for doing the if statment if its ===undefined is not right.
// these two vars i got from the highlighted items in my bin.
var mFinalFile = myPath + myRepFile + zeroAdd +myFormat;
var mFileName = myRepFile + zeroAdd + myFormat;
//establish my new import file
var myImport = new File(mFinalFile);
//if the file isnt in the location...
if (myImport === undefined){
//give an alert
alert("Error: " + mFileName + " missing from this lcoation.");
}else{
//make it a seqence
myImport.sequence = true;
//replace current selected item with the file created from the above process. The "false" is not forcing alphabetical.
item.replaceWithSequence(myImport, false);
}
if (myImport.exists == false)
which can equally be written as:
if (!myImport.exists)
Copy link to clipboard
Copied
I always figure it out 4 seconds after i ask. I needed to use the isValid().
if (isValid(myImport) === false){
//give an alert
alert("Ya done messed up! \r Error: " + mFileName + " missing.");
}else{
//make it a seqence
myImport.sequence = true;
//replace current selected item with the file file created from the above process. The "false" is not forcing alphabetical.
item.replaceWithSequence(myImport, false);
}
Copy link to clipboard
Copied
Dammit! no that wasnt it. Close
Copy link to clipboard
Copied
if (myImport.exists == false)
which can equally be written as:
if (!myImport.exists)
Copy link to clipboard
Copied
thank you. I searched for .exists on:
https://ae-scripting.docsforadobe.dev/
And it came up empty.
Copy link to clipboard
Copied
The After Effects scripting guide doesn't include stuff that is common to all Extendscript apps such as file system and UI. You can find that here:
https://extendscript.docsforadobe.dev/file-system-access/file-object.html#file-object-properties