5 Replies Latest reply on Oct 16, 2012 8:04 PM by hua_li

    Replace lay by script


      Is there a method for use script to replace lay(Ctrl + Alt + / ).


      thank you~

        • 1. Re: Replace lay by script
          Dave LaRonde at Home

          I'm trying to think of something that would be easier than highlighting two layers and then hitting three keys.  I can't think of any.


          Of course, you may not be giving us a full erxplanation of the project and what you need to do.  If true, you should do so.

          • 2. Re: Replace lay by script
            hua_li Level 1

            Thank you for your help, and sorry about didn't make it clear.

            I want to use a script to move/replace movies file to layers if the movie file name and layer name are same.
            I will create a project file which have some layers.(e.g. layers name like AAAA BBBB CCCC)
            There have some movies file named as AAAA.xxx BBBB.xxx CCCC.xxx DDDD.xxx etc
            when its run the script, script file will get all layers name and check whether there have any movie file have same name as layers name.
            if there have same name movie file exist.script will use (Ctrl + Alt + /) function to move/replace movie file to layer.
            in this case, AAAA.xxxx movie file will move/replace to Layer(AAAA),BBBB.xxxx movie file will replace to Layer(BBBB),CCCC.xxxx movie file will replace to Layer(CCCC)

            is it possible?



            • 3. Re: Replace lay by script
              Jonas Hummelstrand Level 2

              Simple workaround if you know the resolution and frame rate of your "new" movies:

              Create a short, empty movie (with alpha.)

              Duplicate that movie a bunch of times on your disk, and rename them AAAA.mov, BBBB.mov and so one.

              Import all into AE and save the project.

              Delete the files on disk.


              Now you have a project that tries to look for and use all your movies from disk. If they exist they will be used instead of your empty movie.

              • 4. Re: Replace lay by script
                Dan Ebberts Level 5

                Something like this should work:



                    function main(){

                        var myComp = app.project.activeItem;

                        if ((myComp == null) || !(myComp instanceof CompItem)){

                            alert("No comp is active.");




                        var myLayer, myItem;

                        for (var i = 1; i <= myComp.numLayers; i++){

                            myLayer = myComp.layer(i);

                            for (var j = 1; j <= app.project.numItems; j++){

                                myItem = app.project.item(j);

                                if ((myItem instanceof FootageItem) && (myItem.name.split(".")[0] == myLayer.name)){












                • 5. Re: Replace lay by script
                  hua_li Level 1

                  Thank you very much, I give it a try.