AE ENHANCERS

Expressions/Scripts/Presets
It is currently Wed Nov 26, 2014 2:38 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Advanced Incremental Save
PostPosted: Sat Apr 23, 2011 12:15 pm 
Offline

Joined: Tue Jan 05, 2010 1:37 am
Posts: 12
One of the places I work for switched their naming convention to have the artists' initials AFTER the version number (i.e. test_v01_sw.aep ), so now the incremental save doesn't work properly. I wrote a short script that now allows you to incremental save with the initials afterword and update the initials if a project switches artists.

Drop it in your ScriptUI folder and now you have a dockable button that lets you easily version up with no hassle.

Enjoy...


Code:


//Version Up! 

//Written by Sam Winkler, 2011.


{
function VersionUp(thisObj)
    {
       
        function  onVersionUpButtonClick()
            {
                var projName=app.project.file.name;

                var projString = projName.toString();

                var curInitials = projString.substring ((projString.length - 6), (projString.length - 4));
   
                var curVersion = projString.substring ((projString.length - 9), (projString.length - 7));
   
                var newVersion = parseInt(curVersion) + 1;
   
                    function pad2(newVersion) {
   
                        return (newVersion < 10 ? '0' : '') + newVersion
   
                            }
   
                newVersion = pad2 (newVersion);
               
               if (  my_palette.grp.optsRow.text_input.text == "" ) {
                    var newInitials = curInitials;
                    } else {
                            var initialsInput = my_palette.grp.optsRow.text_input.text;
                           var newInitials = initialsInput.substring(0, 2);
                    }
                       
               
                var projPath = app.project.file.fsName.toString();
               
                var newProjPath = projPath.substring (0, ( projPath.length - 9)) + newVersion + "_" + newInitials + ".aep";
               
                var newFile = File(newProjPath);
               
                app.project.save(newFile);

               }
   
      function BuildAndShowUI(thisObj)
      {
         // Create and show a floating palette.
         var my_palette = (thisObj instanceof Panel) ? thisObj : new Window("palette", "", undefined, {resizeable:true});
         if (my_palette != null)
         {
            var res =
               "group { \
                  orientation:'column', alignment:['fill','top'], alignChildren:['left','top'], spacing:5, margins:[0,0,0,0], \
                           versionUpButton: Button { text:'Version Up!', maximumSize:[100,40], alignment:['left','top'] }, \
                           optsRow: Group { \
                     orientation:'row', \
                                s: StaticText { text:’Initials:’ }, \
                                text_input: EditText {alignment:['center','top'], characters: 4,}, \
                  }, \
               }";
           
            my_palette.margins = [10,10,10,10];
            my_palette.grp = my_palette.add(res);
           
            // Workaround to ensure the edittext text color is black, even at darker UI brightness levels.
            var winGfx = my_palette.graphics;
            var darkColorBrush = winGfx.newPen(winGfx.BrushType.SOLID_COLOR, [0,0,0], 1);
            my_palette.grp.optsRow.text_input.graphics.foregroundColor = darkColorBrush;
           
            my_palette.grp.versionUpButton.onClick  = onVersionUpButtonClick;
            my_palette.grp.optsRow.text_input.text = "";
            my_palette.grp.optsRow.s.text = "New Initials:";
           
            // Set the callback. When the user enters text, this will be called.

            my_palette.layout.layout(true);
            my_palette.layout.resize();
            my_palette.onResizing = my_palette.onResize = function () {this.layout.resize();}
         }
         
         return my_palette;
      }
   
    //
      // The main script.
      //
      if (parseFloat(app.version) < 8) {
         alert("This script requires After Effects CS3 or later.");
         return;
      }
     
      var my_palette = BuildAndShowUI(thisObj);
      if (my_palette != null) {
         if (my_palette instanceof Window) {
            my_palette.center();
            my_palette.show();
         } else {
            my_palette.layout.layout(true);
         }
      } else {
         alert("Could not open the user interface.", scriptName);
      }
   }
   
   VersionUp(this);
}




Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group