change name based on background image name

I have a camera in max file with background image assigned to it. how can I change the name of the camera to the first 3 letter of the background image file name?

For example if the background image is here: "c:\temp\test34.jpg"
the camera name will be "tes"

I tried this in maxscript listener but got stuck.

bg = backgroundimagefilename
x = filterstring bg "\ "
x[size(x)] <== this line is not working

Thanks for any help.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miauu's picture

.

(
	bgImagePath = "c:\\temp\\test34.jpg"
	bgImageName = getFilenameFile bgImagePath
	first3chars = bgImageName
	str = substring  bgImageName 1 3
	format "str: % \n" str
)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.