• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Alert prompt is a file is missing when trying to import

Explorer ,
Apr 14, 2021 Apr 14, 2021

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);     
                                    }

 

TOPICS
Scripting

Views

312

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

Enthusiast , Apr 15, 2021 Apr 15, 2021

if (myImport.exists == false)

which can equally be written as:

if (!myImport.exists) 

Votes

Translate

Translate
Explorer ,
Apr 14, 2021 Apr 14, 2021

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);     
                                    }

Votes

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
Explorer ,
Apr 14, 2021 Apr 14, 2021

Copy link to clipboard

Copied

Dammit! no that wasnt it. Close

Votes

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
Enthusiast ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

if (myImport.exists == false)

which can equally be written as:

if (!myImport.exists) 

Votes

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
Explorer ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

thank you. I searched for .exists on:
https://ae-scripting.docsforadobe.dev/

And it came up empty.

Votes

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
Enthusiast ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

LATEST

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

Votes

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