(MEL)writing a renamer script.

(MEL)writing a renamer script.

absoluteKelvin
Collaborator Collaborator
1,039 Views
3 Replies
Message 1 of 4

(MEL)writing a renamer script.

absoluteKelvin
Collaborator
Collaborator

im currently stuck on a supposedly straightforward section of my script. Im writing a script that is striping the Suffix of the naming. To do that im using tokenize to separate and store the strings after "_". But im stump on the why it doesnt print the result.

 

{
    string $userSel[]=`ls -sl -transforms`;
    string $buffer[];
    int $token;
    for ($node in $userSel){
        $token = `tokenize $node "_" $buffer`;
        print $buffer[$token];
    }

}

Thanks

 

https://www.artstation.com/kelvintam
0 Likes
1,040 Views
3 Replies
Replies (3)
Message 2 of 4

trs_andre
Collaborator
Collaborator

Hi!

 

The result of the tokenize command is the number of tokens in which the string is split, so if you tokenize "hello_world" with the "_" character, the result will be 2.

 

So, in this case, buffer will only be populated in the position 0 and 1, so printing buffer[2] will return nothing.

Might this be your case?

André Moreira

Game Developer / Technical Artist

LinkedIn

Message 3 of 4

rajasekaransurjen
Collaborator
Collaborator

Hi, Try This...

 

{
    string $userSel[]=`ls -sl -transforms`;
    string $buffer[];
    int $token;
    for ($node in $userSel){
        $token = `tokenize $node "_" $buffer`;
        print $buffer[($token-1)];
    }

}
Message 4 of 4

absoluteKelvin
Collaborator
Collaborator

it works perfect! thanks

https://www.artstation.com/kelvintam
0 Likes