Last active
October 19, 2015 22:29
-
-
Save berniebernie/015da6b46ef69e3e35d1 to your computer and use it in GitHub Desktop.
saves incrementally with a padding of 2, prompts for the name http://i.imgur.com/2GeQRpR.jpg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| proc incrementAndSave(){ | |
| //takes the current scene, increments (or adds '01' suffix if none found). Padding set to 2 | |
| //so many regexes because I suck at this | |
| string $path = `file -q -loc`; | |
| $path = `match "^.*/" $path`; | |
| string $file = `file -q -sn -shn`; | |
| $ext = fileExtension($file); | |
| $file = `match "^[^\.]*" $file`; | |
| string $suffix = `match "[0-9]+$" $file`; | |
| $file = `match ".*[^0-9]" $file`; | |
| int $suff = 1; | |
| if($suffix != ""){ | |
| $suff = $suffix; | |
| $suff++; | |
| } | |
| $suffix = ($suff<10)?"0"+$suff:$suff; | |
| $fileprompt = `promptDialog -text ($file+$suffix+"."+$ext) -title "Save as" -message "New file name:" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel"`; | |
| if($fileprompt == "OK"){ | |
| $scene = `promptDialog -q -text`; | |
| $type = (`tolower $ext` == "ma")?"mayaAscii":"mayaBinary"; | |
| file -rename ($path+$scene); file -save -type $type; | |
| } | |
| } | |
| incrementAndSave; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment