[Closed] How to get max file name?
Such as D:\max[b]test.max ,[/b] just to get the max name : test .
Thanks
The system global variable maxFileName contains the file name of the scene currently loaded.
The system global variable maxFilePath contains the path of the scene.
So if you want the current scene name, you can get it from there.
If you already have the path in a variable, then use getFileNameFile() (gives you just “test”, as already mentioned) or filenameFromPath() (will give you “test.max”).
getFilenameFile <filename_string> –returns the file name part of a full file name
Think that should do it for you.
[QUOTE=Bobo]…QUOTE]
Thank you BoBo…I got that…
There’re some max files in a folder, so i can’t offer there path one by one…
Maybe i just to get the file name use “maxFileName”,then i can get the name “test.max”
But how i delete “.max”,just keep “test”…?
rarnett and Bobo both gave you the answer, lookup getFilenameFile in the manual.
Martijn
Of couse, i understood what bobo said…
I can get the name “test.max”,but there isn’t method about how to delete “.max” in the help document…
And if someone couldn’t help me , just left here…and please don’t say “look help”…like other body!
Thanks!
You seem not to like to do the work for yourself (not just here, but in other posts as well). You clearly do not understand what Bobo and rarnett said. They gave you exactly the answer you’re looking for. But because you won’t look it up, I’ll do it for you:
This is pasted in from the help:
file=“g:\subdir1\subdir2\myImage.jpg”
filenameFromPath file – returns: “myImage.jpg”
getFilenamePath file – returns: “g:\subdir1\subdir2”
getFilenameFile file – returns: “myImage”
getFilenameType file – returns: “.jpg”
pathIsNetworkPath “c:\ emp\ est.txt” –returns: false
pathIsNetworkPath “\\someserver\ emp\ est.txt” –returns: true
So which one do you think will “delete” the .max?
Hi focomoso:
First.
I didn’t blame bobo and rarnett ever, so i don’t know what your purpose you say…
When i post, BoBo and rarnett told me how to do quickly, i need to thank them.
Second.
My problem is: how to get “test”,not “test.max”,and i said i didn’t know the path because there’re some max files in folder and there will be some max files need to be add, I want to rename my scene name same as the max files , who know my next max files’s name is? Will i write the cod for the files one by one?
Under the circumstances, somebody told me to look “getFileName” in help again…Is it useful above you mentioned? Sorry i don’t know the path,because the files is variational.
But as “dunkelzahn” mentioned, It’s a walk in the park for solveing my problem for every files.
Third.
In my post, somebody come to help me and give me some propositional , i’m very glad and i must to thank you…But i’m weary someone who didn’t get my meaning then said random and the same answer after somebody…It’s meaningless and irresponsible…Like Martijn…He clearly didn’t get my meaning…
Apart from this, i'm learning script do my best and i like it.
Thank you dunkelzahn it's sapiential...
Hehe, the answer is right before you…
…being new to Max Script myself I´ll give you a hint. Try combining some of those parameters like maybe
getFilenameFile maxFilename
who knows what will happen
Oh, and if you have a value like a file name and a path seperately, you can add then together like
variable1 = Enter your first command here
variable2 = Enter your second command here
Conclusion = variable1 + variable2
Start playing around with the code and have fun
Chris
I’m doing max scripting for many-many years, but every day I have my MAX Script Help opened. And every day I double check my work with the Help.
You can study max scripting for years by looking in someone else’s codes but if you ignore reading help you would never really learn scripting or another coding.
-- how to get filename file
str = "text.txt"
-- 1.
getFilenameFile str
-- 2.
(filterString str ".")[1]
-- 3.
substring str 1 ((findstring str ".") - 1)
-- 4.
substitutestring str (getfilenametype str) ""
-- 5.
replace str (findstring str ".") (str.count - (findstring str ".") + 1) ""
-- 6.
replace str (findstring str (getfilenametype str)) (getfilenametype str).count ""
-- 7,8,9...
Yes. denis…
I gotta remember what you say during learning script, it’s very correct…
Thanks for your help and encouragement.
What’s wrong with:
str = “test.txt”
“test.txt”
getFilenameFile str
“test”
Done!