Notifications
Clear all

[Closed] Find a file in different location

Hello,
Here is what I’m trying to do:
I have a path for the max file: C:\GIT\Projects\Revolution\MaxProgramming, however between other coworkers and I, the lead in to the max file could be different. For example C:\User01\Jobs\Revolution\MaxProgramming, C:\User02\Work\Revolution\MaxProgramming etc. Is there a way that I can get maxscript to read the path data and step back a few folders to read a file in the “Revolution” directory?

Our end goal is to read a CSV file created from a different program.

Thank you

4 Replies

(
    folder1 = @"C:\User01\Jobs\Revolution\MaxProgramming"
    folder2 = pathconfig.removepathleaf folder1
    
    print folder1
    print folder2
)

Thank you for the quick reply, that did the trick for what I needed. One follow up question, if I wanted to go back one more folder, than I would do the same, and add for example

folder3 = pathconfig.removepathleaf folder2?

Yes, you could do that or have a little function like:


(
    fn RemoveFolderLeaf folder amount =
    (
        for j = 1 to amount do folder = pathconfig.removepathleaf folder
        return folder
    )
    
    folder = @"C:\User01\Jobs\Revolution\MaxProgramming"
    RemoveFolderLeaf folder 3
)

That function will help a lot in the future I’m sure. Thank you so much for the help. I did get a chance to try the original script and it worked perfectly. Again thanks for the quick reply.