View Full Version : REnaming unsequential objects to sequential objects?????

12-19-2005, 01:42 PM
hello all ,
I am pretty new to MEL and I am having trouble (I cant do it) renaming some lights that are numbered with spaces between the numbers i .e 36 37 38 45 46 47 48 53 54 54 to a different name that is sequential 1 2 3 4 5 6 7 8 9...

the bit of code i will type works until it hits a gap in the number sequence .I've tried allsorts of things and the best i can do is make maya crash!!!

so ....

int $From = 37;
int $To == 1;

rename ("Old"+$From) ("New"+$To);
$From = $From + 1;
$To = $To + 1;
while ($From < 100);

any help would be very much appreciated



12-19-2005, 02:47 PM
Select all your lights and run this:

$lights=`ls -sl`;
for ($i=0;$i<size($lights);$i++) {
rename ($lights[$i]) ($prefix+($i+1));

Change "prefix" to whatever you want it to be, and it'll rename your lights prefix1, prefix2, prefix3, etc.

12-20-2005, 05:30 AM
Thanks BoneDaddy,

i actually managed to achieve what i wanted by telling the script to pick walk from a certain number upto a certain number and then rename the selection as it goes.... but i'll have at look at your code anyway ,as I have hit another problem which i think "for" may well solve:)

thanks again


CGTalk Moderation
12-20-2005, 05:30 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.