Collecting textures?

I'm trying to write a script which collects the texturemaps in use and adjusts the filenames so that they're in 8.3 format, but I'm having a hard time with it.


The filenames path in the bitmap texture can be incorrect and max then uses the "Also search in" list to figure out where the texture really is, but it doesn't update that information.


The resource collector does what I want to do perfectly, but I want to embed its code in my script so the user doesn't have to do anything. Does anyone know how the utility works behind the scenes or how I can call it via MaxScript (Max8)?

fn shortenBitmap bit saveFolder = (
format "Filename: %\n" bit.filename
filename = getFilenameFile bit.filename
-- Remove _'s spaces, etc.
fileArray = filterString filename "_ ,."

-- Combine what is left of the filename
newFilename = ""
for elm in fileArray do (
newFilename += elm
newFilename = subString newFilename 1 8
type = getFilenameType bit.filename
newFullPath = saveFolder + newFilename + type
format "New filename: %\n" newFullPath
copyFile bit.filename newFullPath
bit.filename = newFullPath