Parsing help

got a problem i’m going to throw out, and see if anyone can help me. I’m parsing a file name out to get some info stored in the name, then trying to rebuild the name without the aforementioned info. so something along the lines of

filterstring “blah_animation5_f5-f20.max” “_”
–> #(blah, animation5, f5-f20)

now i need to take everything in the array but the last entry and rebuild it to blah_animation.max.

I think i need to build a loop that recursively adds the array entries to the last one, but i’m not sure how.
something like

for i = 1 to (array.count-1)
append array.[i] “_”

but that will only get me “blah_” and “animation_”

I’m not sure where to go from there. any help?

thanks!

You want to get “blah_animation.max”, right? you could do this:

newfilename = “”

for i = 1 to (array.count-1)
newfilename += array[i]+"_"

newfilename = (trimright newfilename “_”) + “.max”

ugly, but effective :slight_smile:

yeah, i just got a reply from cgtalk with the same method. I was not aware that i could do a += operation on string variables. there really has to be a better way to learn this than trial and error :sigh: :slight_smile:

thanks for the help, tim!

btw, i also wanted to thank you for setting up or at least officiating the TA panel at GDC last month. it was great to see there are others doing what i do and meet them.

thanks again

-ian

Glad to help, and glad you enjoyed the roundtable! I hope to continue running it for years to come, or they kick me out for being irrelevant :slight_smile:

Just throwing this out there, but instead of trying to fit all of the information you need into the filename, why not just put your metadata into the file properties of the file? This would provide a lot more flexibility and readability of the files. :slight_smile:

how do you do that? I’ve seen file properties around, but haven’t messed around with it due to lack of time, and fear of breaking things.

-ian