PDA

View Full Version : find filename in a folder


lellis2k
04-20-2009, 04: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?

LoneRobot
04-20-2009, 04: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.

Kameleon
04-20-2009, 05:08 PM
Have you tried this:

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

Cheers.

lellis2k
04-20-2009, 05:22 PM
that gives "Z:\BWS\max\G11.max", thanks anyway.

will try lonerobot's suggestion now

Kameleon
04-20-2009, 05:22 PM
I stand corrected....

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

lellis2k
04-20-2009, 05:36 PM
Works like a charm, thanks dude!

CGTalk Moderation
04-20-2009, 05: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.