View Full Version : find filename in a folder

04 April 2009, 03:51 PM
Hey Guys,

my script finds max files in a set directory named like the current selection:

files = getFiles (trydir+$.name+"*.max")

gives this output: #("Z:\BWS\max\G11.max")

i want to get just the filename, i.e. "G11.max"

Any ideas how I can do this?

04 April 2009, 03:58 PM
Hi leigh, check out the topic File Name parsing in the maxscript help. you will find a function called getfilenamefile <file string> that you can use to do this.

if you also check the external file methods topic you will find a recursive search function for finding files in nested folders, which might help you with your other post.

04 April 2009, 04:08 PM
Have you tried this:

files = (getFiles (trydir+$.name+"*.max"))[1]


04 April 2009, 04:22 PM
that gives "Z:\BWS\max\G11.max", thanks anyway.

will try lonerobot's suggestion now

04 April 2009, 04:22 PM
I stand corrected....

files = filenameFromPath (getFiles (trydir+$.name+"*.max"))[1]

04 April 2009, 04:36 PM
Works like a charm, thanks dude!

CGTalk Moderation
04 April 2009, 04:36 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.