[Maya]Incremental Save - script for Maya

Please feel free to add your own scripts that you find useful for 3ds MAX and/or Maya!
Post Reply
User avatar
Luigi Tramontana
Posts: 358
Joined: Mon May 19, 2008 11:32 am
Location: Gothenburg, Sweden
Contact:

[Maya]Incremental Save - script for Maya

Post by Luigi Tramontana » Thu Sep 18, 2008 5:42 pm

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;
};

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests