Its been a while..

I’ve been knuckled down with working full time! But its time to get back onto this blogging business.
Starting with revisiting an old tool feels appropriate!
Having written a tool for upsaving your scene some years ago
I’ve since learned a lot about string formatting and array navigation in Python.
The tool is simple, it finds out where your current scene is located and its name,
then looks for a number at the end of the name, adds 1 to it and saves the file, with the new name in
the same directory.

def upSaveScene():
	currentFileLocation = cmds.file( query = True, location = True )
	currentFileName = currentFileLocation.split( '/' )[-1]
	if '.mb' in currentFileName:
		stripExtension = currentFileName.replace('.mb','')
	if '.ma' in currentFileName:
		stripExtension = currentFileName.replace('.ma','')
	versionNumberString = stripExtension.split( '_' )[-1]
	if versionNumberString.isdigit():
		versionNumber = int(versionNumberString)
		newVersionNumber = versionNumber + 1
		newFilename = currentFileName.replace( str(versionNumber), str(newVersionNumber) )
	if not versionNumberString.isdigit():
		newFilename = stripExtension + '_01'
	newFilenamePath = currentFileLocation.replace( currentFileName, newFilename )
	
	cmds.file( rename = newFilenamePath )
	cmds.file( save = True, f = True )