Page 1 of 1

[Maya]Incremental Save - script for Maya

Posted: Thu Sep 18, 2008 5:42 pm
by Luigi Tramontana
Incremental Save - script for Maya

Usage: Saves your current scene as a new file with its last two numbers increased by one, or if there are no numbers at the end adds " 01" to the file name.

Code: Select all

{
// Author: Luigi Tramontana @ Craft Animations
// S++: Incremental Save
// Usage: Saves your current scene as a new file with its last two numbers increased by one, or if there are no numbers at the end adds " 01" to the file name.

$currentFilePathName = `file -q -sceneName`;
$currentFileType = `file -q -type`;
$fileType = endString( $currentFilePathName, 3);
$currentBaseName = basenameEx( $currentFilePathName);
$lastTwoChars = endString( $currentBaseName, 2);
if( strcmp( $lastTwoChars, "99") == 1)
{
	$currentFilePathName = startString( $currentFilePathName, `size $currentFilePathName` - 3)  + " 01" + $fileType; 
}
else
{
	$lastTwoCharsAsIntIcr = (int) $lastTwoChars; 
	$lastTwoChars = "";
	$lastTwoCharsAsIntIcr = $lastTwoCharsAsIntIcr + 1;
	if( $lastTwoCharsAsIntIcr < 10)
	{
		$lastTwoChars = (string) 0;
	}
	$lastTwoChars = $lastTwoChars + (string) $lastTwoCharsAsIntIcr;
	$currentFilePathName = startString( $currentFilePathName, `size $currentFilePathName` - 5)  + $lastTwoChars + $fileType; 
}
file -rename $currentFilePathName;
file -save -type $currentFileType;
};