PLEASE HELP! Get maxFileName first 5 digits or letters


#1

hello I am trying to get a maxFileName but i only want the first 5 digits of the file name so i can save out a fbx with that file name and also minus the .max at the end

this is what i got so far (sorry i am new at this so i know my code sucks)

max select all

sel = selection as array
fileName = maxFileName
folder = @“E:\su_files\FBX EXPORT\” --your path
ext=".fbx" --your extension
exportFile (folder+fileName+ext) #noPrompt selectedonly: true


#2
(
	max select all

-- 	sel = selection as array
	fileName = getFilenameFile maxFileName
	folder = @"E:\su_files\FBX EXPORT\" --your path
	ext=".fbx" --your extension
	exportFile (folder+fileName+ext) #noPrompt selectedonly: true
)

What do you mean by “but i only want the first 5 digits of the file name”? Can you give an example of “file name”?


#4

wow thanks a lot for replying so quick sorry agian to pm you

its
saving it like
01_0092_00_Thumbnail_Zelcova Serrata ‘Green Vase’_100_0007.fbx

but i want

01_0092_00.fbx


#5

so its the first 10 digits my bad


#6
(
	max select all

-- 	sel = selection as array
	fileName = substring (getFilenameFile maxFileName) 1 10
	folder = @"E:\su_files\FBX EXPORT\" --your path
	ext=".fbx" --your extension
	exportFile (folder+fileName+ext) #noPrompt selectedonly: true
)

If you need the first 5 characters of the file name use this:
fileName = substring (getFilenameFile maxFileName) 1 5


#8

OMG you are a legend

can you pm me your paypal address
I can give you a little something for the help when this project is done next week

also i know i am asking a lot but how can i get it to save into its own folder with the 10 digit file name?


#9

What have to be the name of the “own folder”? The same as the name of the file(10 digits name)?


#11

yes same as the name of the file(10 digits name)


#12

Try this:

(
	max select all

	fileName = substring (getFilenameFile maxFileName) 1 10
	fullFolderPath = @"E:\su_files\FBX EXPORT\" + fileName + "\\"
	if doesFileExist fullFolderPath == false do
	(
		makeDir (@"E:\su_files\FBX EXPORT\" + fileName + "\\")
	)
	ext=".fbx"
	exportFile (fullFolderPath+fileName+ext) #noPrompt selectedonly:true
)

#13

OMG perfect thanks

really really thanks for the help

don’t forget to pm your paypal


#14

I did it. Check your PM.