Rename Duplicates
Mel Scripting January 11th, 2008
Description : This script will find any duplicate names in your Maya scene and rename them to a different one by adding “1″ at the end of the name. You will know if in the script editor you see a node name has been changed, otherwise there’s none. However, this script doesn’t find duplicate Shape names. Please save your works before run this script!
global proc s_renameDuplicate()
{
string $nodes[]=`ls -type transform`;
global int $count;
$count =1;
for ($x=0; $x< size($nodes); $x++ )
{
int $num_token = 0;
string $buffer[];
$num_token =`tokenize $nodes[$x] "|" $buffer`;
if ($num_token > 1)
{
while ($num_token > 1)
{
string $name =($buffer[size($buffer)-1]);
rename $nodes[$x] ($name + $count);
print ("renamed " + $nodes[$x] + " to " + ($name + $count) + "\n");
//$count++;
$nodes =`ls -type transform`;
string $buffer[];
$num_token =`tokenize $nodes[$x] "|" $buffer`;
}
}
}
}
June 20th, 2011 at 4:40 am
Good script!
Thanks!