Categories
code of the day cotd

Code of the Day: BatchRename

Creative crash site again today with the BatchRename script by Shepherd: https://www.creativecrash.com/maya/downloads/scripts-plugins/c/batchrename

This script allows files to be renamed based on prefix, base name, base number and format. It selects all the files in the directory and renames them based on the order returned from os.listdir()

Language: Python
Type: Maya Editor Script
Script Files: 1
Number of lines: 234

Functionality: 7
The functionality is decent, allowing a number of options for renaming the file, but not a significant amount. One thing I think would be a wortwhile change would be to allow an artist to search for a path, instead of typing it out. This is less error prone, more intuitive, and possibly quicker than typing out the path by hand. It would be nice to see a few options in the naming options, but it will cover a lot of cases with currently.

Design: 6
The main code has a number of duplications, and some of the code is nested quite deeply in loops and if statements (which also have some repeated code). The code does a lot of branching within a single function which makes following the execution path harder to follow with so many branches in a single function.

Style: 5.5
The code style is consistent which is helpful. Outside of the large branching issues I mentioned, the code also has a number of spelling mistakes (both on functions and variables). The code would also benefit from some additional comments and a little more use of spacing between variables and function parameters.

Documentation: 5
Outside of the header, the code does not have any comments in it (besides some commented out code). The header file has a lot of standard stuff, but not a lot of description. The code could benefit from a little bit of documentation, at least in what it is supposed to do.

Reusability: 6
The code base is not very big, but also does not appear to have any reusable functions. Most of the code is tied closely with grabbing the interface values, but more importantly is quite complex in terms of nested scope, which will likely cause a few issues to be aware of.

Overall: 6.5
The functionality does as it advertises, but it would be nicer to have a few additional options. Another very helpful option would be able to choose which files to include in the filter results. The script appears like it would rename everything in a folder, which may have more uses besides render output, but could also be potentially troublesome if used on the wrong directory (another reason to make the selection of the folder an option). Overall, the script does as it advertises, but a number of other tools and scripts can perform a similar task as well.

Until next time,
Michael Hubbard
https://michaelhubbard.ca

Leave a Reply

Your email address will not be published. Required fields are marked *