Expressions/Scripts/Presets

Moderator: Paul Tuersley

 
berniebernie
Topic Author
Posts: 31
Joined: Mon Feb 07, 2005 7:32 am
Contact:

Automatic 'Send To Watchfolder'

Mon Apr 16, 2012 3:53 pm

I posted on reddit: http://www.reddit.com/r/AfterEffects/co ... _of_comps/ but if you're on AEnhancers you know better; basically it's a tiny tool to send your project to a watchfolder without have to do a nasty collect files.

Image

Save as .jsx in the scriptsUI folder

/*
Watchfolder.js v1.0
--------------------
By bernie @ berniebernie.fr

This script is a simple palette to automatically send your after effects file to be processed by the watchfolder
In essence it's a simplified Collect Files > Project only.
*/
{                 
watchfolderLocation = "none";
watchfolderLocation = (app.settings.haveSetting("watchfolderPrefs", "watchfolderLocation"))?(app.settings.getSetting("watchfolderPrefs", "watchfolderLocation")):watchfolderLocation;

function sendToWF(wf){
        var c = confirm(app.project.file.name+" needs to be saved first. Save ?",false,"Save Project");
        var saved = app.project.file.toString();
        if(c){
            app.project.save();
            var curFile = app.project.file.name;
            curFile = curFile.substring(0,curFile.length-4);
            var myFolder = new Folder(wf+"/"+curFile+"_watch/");
            myFolder.create();
            curFile += "_watchfolder";
            var mySaveFile = new File(myFolder.toString()+"/"+curFile+".aep");       
            app.project.save(mySaveFile);
            var myTextFile = new File(myFolder.toString()+"/"+curFile.substring(0,22)+"_RCF.txt");   
            myTextFile.open("w","TEXT","????");
            var text = "After Effects 10.0v1 Render Control File\nmax_machines=5\nnum_machines=0\ninit=0\nhtml_init=0\nhtml_name=\"\"\n" ;
            myTextFile.write(text);
            myTextFile.close();
            app.project.close(CloseOptions.DO_NOT_SAVE_CHANGES);
            var opFile = new File(saved);
            if(opFile){
                app.open(opFile);
            }           
            writeln("Sent to watchfolder...");           
    }
}
function setWatchFolder(){
        var y = confirm("Watchfolder is currently set to \n\n\""+watchfolderLocation+"\"\n\nChange it ?");
        if(y){
            var v = Folder.selectDialog ("New watchfolder location").toString();
            if(v!=null && v!="undefined"){
                app.settings.saveSetting("watchfolderPrefs", "watchfolderLocation",v);     
                watchfolderLocation = v;
            }
        }
    }
 function watchFolderUI(thisObj){
    pan = (thisObj instanceof Panel) ? thisObj : new Window("palette", "Watchfolder", [100, 100, 300, 300]);
    var securitySetting = app.preferences.getPrefAsLong("Main Pref Section", "Pref_SCRIPTING_FILE_NETWORK_SECURITY");
    if (securitySetting != 1) {
        pan.add("statictext",[15,15,300,45],"Set prefs and re-launch");
        alert("You need to check \"Allow Scripts to Write Files and Access Network\" in your preferences for this script to work");
     }else{
                var res =
            "group { \
                        alignment: ['fill','fill'], \
                        alignChildren: ['fill','top'], \
                        orientation: 'column', \
                            setWF: Button {text: 'Set watchfolder' ,preferredSize:[-1,30]} , \
                            sendWF: Button {text: 'Send To Watchfolder' ,preferredSize:[-1,30]} , \
                    }";   
            pan.grp = pan.add(res);       
            pan.grp.setWF.onClick = function () {
                    setWatchFolder();
                    }
            pan.grp.sendWF.onClick = function () {
                if(watchfolderLocation=="none"){
                    setWatchFolder();
                    }else{
                       
                    sendToWF(watchfolderLocation);
                }}
            pan.layout.layout(true);
            pan.layout.resize();
            pan.onResizing = pan.onResize = function () {this.layout.resize();}
            return pan;
    }
}
watchFolderUI(this) ;
}
Boom boom boom.

Who is online

Users browsing this forum: No registered users and 1 guest