XM Magdalena 3D print, GGeorgy (3D)
LC #42 Pipers Alley

View Full Version : How to remove the extension?

10-25-2005, 03:45 PM
Hi guys. I have a doubt. Imagine I run a code line that gives me the path of a specific material texture. It can be, for example, "c:\project\Hello.jpg" --> This is what the command return. So, how can I remove the extension, so I can can tell maya to search for a "c:\project\Hello.tif" and not a JPG?
the following is just an example, for you guys understand better:

string $file = ""c:\project\Hello.jpg";

if I tell Maya to change this I could use:

theCommandToChangeTheFile ($file + ".tif");

but if I use this, it will tell maya that the image is "c:\project\Hello.jpg.tif" and not "c:\project\Hello.tif"

Can I somehow "erase" the three last letters?

Thanks for your help


10-25-2005, 03:54 PM
Look up the tokenize command

10-25-2005, 04:00 PM
but the tokenize only returns numbers...Am I wrong?

I was thinking of using the command basename and dirname, mix them together, and end up with something like ($dir + $fileName + ."tif")

gonna both methods.. Thanks drGonzo


10-25-2005, 04:45 PM
tokenize separates chops up a string based on another string. So, for this, you want it to separate stuff before and after the period. So use a period as the argument in your tokenize calls.

string $string="c:/poop/poop.jpg";
string $buffer[];
tokenize ($string, ".", $buffer);
print $buffer[0]; // this will come out as c:/poop/poop
print $buffer[1]; // this will come out as jpg
print ($buffer[0] + ".tif") // this will come out as c:/poop/poop.tif

I may have gotten the order of the tokenize arguments wrong.

10-25-2005, 05:04 PM
Thanks a lot bonedaddy. that was really what I needed. I own you one.


CGTalk Moderation
10-25-2005, 05:04 PM
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.