Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions app.scheduleTask()

  • app.scheduleTask()

    Posted by Fabio Apelbaum on July 11, 2016 at 3:22 pm

    Hi guys, happy monday to all!

    I am trying to understand more about app.scheduleTask() so I set a quick script that creates a Temp folder in my desktop, then saves my current open project inside the folder and then I am trying to set a scheduleTask to delete the file and the folder after certain amount of time.


    function tempFile(theFolder, theFile){
    var folderPath, theFolder, filePath, theFile;

    folderPath = "~/Desktop/"+theFolder
    theFolder = new Folder (folderPath.toString());
    filePath = folderPath +"/"+ theFile + ".aep"
    theFile = File(filePath.toString());

    theFolder.create()
    app.project.save(theFile);

    var str = "theFile.remove();\
    theFolder.remove();"

    app.scheduleTask(str,1000,false);
    }

    tempFile("TempFld2", "test_002")

    For some reason the app.scheduleTask is not finding the paths to the folder and file, it just doesnt want to look inside the variable, when I try this with an alert(), the file path comes as undefined. Am I missing something, is it because the app.scheduleTask is inside a function?

    Thanks all for your help!

    Fabio

    Fabio Apelbaum replied 9 years, 10 months ago 2 Members · 2 Replies
  • 2 Replies
  • Miguel De mendoza

    July 12, 2016 at 1:01 am

    I’ve tryed yor code. The toolkit has created a new source file and opened it with this content:
    theFile.remove();
    theFolder.remove();

    So, it throws an error, because in the new file theFile is not defined. What you can do is add an include statment, referencing your script, but you must call app.scheduleTask from other file, because if you call it in the same script, the function will run and run until you close after effects. Other problem is that your variables are inside of a function so they are not accesible from outside. You can solve it by some ways, this is my aproach:

    //Script 1:
    {
    var TempFile = new Object();
    TempFile.folderPath = "~/Desktop/tempFldr2";
    TempFile.theFolder = new Folder (TempFile.folderPath.toString());
    TempFile.scriptPath = (new File($.fileName)).toString();
    TempFile.str = "TempFile.theFolder.remove();"
    TempFile.theFolder.create()
    }

    //Script 2:
    {
    #include "Script1.jsx"
    app.scheduleTask(TempFile.str,1000, false);
    }

  • Fabio Apelbaum

    July 12, 2016 at 7:47 pm

    thanks!!! thats awesome!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy