Notifications
Clear all

[Closed] find filename in a folder

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?

5 Replies

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.

Have you tried this:

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

Cheers.

that gives “Z:\BWS\max\G11.max”, thanks anyway.

will try lonerobot’s suggestion now

I stand corrected…

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

Works like a charm, thanks dude!