At this new section will hold all my scripts
Script for rename one or many selected Objects
//———————————————————————-
//———————————————————————-
// Script by Cleber Coutinho 7/10/2009
// Script that rename All Selected Objects
//———————————————————————-
//check if the window exists. have a TextScrollList+Button to get selected Objects
// input text and a button to rename.
global proc ctcRenameSel()
{
if(`window -exists ctcRenameWindow`)
{
deleteUI ctcRenameWindow;
}
window -title “CTC_Rename_Window” -mxb 0 ctcRenameWindow;
columnLayout -h 150 -adj 1 -bgc 1 1 2 ctcRenameCol;
textScrollList -h 150 ctcRenameTSL;
button -label “Get Selected Objects” -c populateTSL getButton;
separator -w 400 -style “out”;
textField ctcRenametextField;
button -l “Rename!” -c renameProc renameButton;
showWindow ctcRenameWindow;
}
///////////////////////////////////////////
// Get all objects and store into array
// Populate TSL
//////////////////////////////////////////
global proc populateTSL()
{
//clear TSL
textScrollList -e -ra ctcRenameTSL;
//Store All selected Objects
string $sel[]= `ls -sl`;
//populate TSL
for($each in $sel)
{
textScrollList -e -append $each ctcRenameTSL;
}
}
//——————————————–
//RENAME PROCEDURE
//——————————————–
global proc renameProc()
{
string $objectsInSTL[] =`textScrollList -q -ai ctcRenameTSL`;
//new Name from user input
string $newName=`textField -q -text ctcRenametextField`;
for($eachIn in $objectsInSTL)
{
rename $eachIn ($newName + “_#”);
}
populateTSL;
}
////////////
ctcRenameSel;
Leave a comment