Skip to main content
Participant
April 6, 2015
Question

Script to import a file into AE

  • April 6, 2015
  • 2 replies
  • 2193 views

Hi there,

I am looking into how to write a script that allows me to import a file.

I have created a camera rig a few months which I now usually manually import (just import the AEP into my project)

But I would like to have a script that allows me to have the AEP located in th AE scripts folder, together with the scipt and will let me import it by just running the script. (just to be clean, I don't mean expressions, I mean a javascript file that imports a certain file to my project)

I don't really know much about scripting and can't find a solution anywhere.

If anyone can help that would be greatly appreciated.

This topic has been closed for replies.

2 replies

Tomas Sinkunas
Legend
July 25, 2015

I know this is an old thread, but I think it's worth mentioning.

There is a script Bookmarker - aescripts + aeplugins - aescripts.com

that let's you bookmark your projects and import them by double clicking on their name in the script UI. This might be usefull in your case. Even in trial mode it will work fine.

Cheers.

April 7, 2015

Here is the code.Run it and choose your project file,then AE will import it for test and show a window with final text,which is what you want.Copy the text ,create a *.jsx,and you can run it whenever you like.By the way, if you want AE to run the script automatically when open AE  ,try to copy the script to the Folder ("After Effects Path\Support Files\Scripts\Startup");

function importProject(file) {

    if (file != null) {

        var f = new ImportOptions();

        f.file = file;

        f.forceAlphabetical = false;

        f.importAs = ImportAsType.PROJECT;

        f.sequence = false;

        if (f.canImportAs(ImportAsType.PROJECT)) {

            try{f = app.project.importFile(f);

        w = new Window("palette");

        text = w.add("EditText{properties:{multiline:true,scrolling: false},preferredSize:[180,300],text:'',enabled:1}");

        text.text = "function importProject(file) {"+ "\r" +

"    if (file != null) {"+ "\r" +

"        var f = new ImportOptions();"+"\r" +

"        f.file = file;"+"\r" +

"        f.forceAlphabetical = false;"+"\r" +

"        f.importAs = ImportAsType.PROJECT;"+"\r" +

"        f.sequence = false;"+"\r" +

"        if (f.canImportAs(ImportAsType.PROJECT)) {"+"\r" +

"            f = app.project.importFile(f);"+"\r" +

"        }"+"\r" +

"    }"+"\r" +

"}"+"\r" +

"importProject(File(\"" +file.toString() +"\"));"+"\r" +

"        ";

        w.show();

        }catch(err){alert(err);}

        }

    }

}

importProject(File.openDialog("Please select the project file.", "*.aep", false));