Drop it in your ScriptUI folder and now you have a dockable button that lets you easily version up with no hassle.
Enjoy...
Code: Select all
//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);
}