Problem with custom Incremental Save script
Posted: April 21st, 2011, 9:06 am
Hello!
I recently wrote a new script for the place I am currently working. Their naming convention does not allow me to use AE's incremental save button, because they use the artists initials AFTER version number (i.e. "boyrunning_v04_sw.aep").
So I wrote a script posted below that will incrementally save while accounting for the initials. I also tried to add a function allowing the user's initials to be switched, but it is not working for some reason. The EditText box I am using gets this weird "NaN" not a number error for some reason and it also does not update the initials into the new file name. Any advice?
I recently wrote a new script for the place I am currently working. Their naming convention does not allow me to use AE's incremental save button, because they use the artists initials AFTER version number (i.e. "boyrunning_v04_sw.aep").
So I wrote a script posted below that will incrementally save while accounting for the initials. I also tried to add a function allowing the user's initials to be switched, but it is not working for some reason. The EditText box I am using gets this weird "NaN" not a number error for some reason and it also does not update the initials into the new file name. Any advice?
Code: Select all
//Version Up!
{
function VersionUp(thisObj)
{
function onTextInputChange()
{
var newInitials = this.text;
}
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 ( typeof(newInitals) == "undefined" ) {
var newInitials = curInitials;
} else {
}
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,20], alignment:['center','top'] }, \
optsRow: Group { \
orientation:'row', \
s: StaticText { text:’Initials:’ }, \
text_input: EditText { text: ’’, alignment:['center','top'], characters: 2,}, \
}, \
}";
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.onChange = onTextInputChange;
// 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.", scriptName);
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);
}