relative paths

dave walker's icon

Hey guys,

does anyone know how to set up relative paths that aren't within the max application folder? i want to select a folder that is in the same level as my patch and read the relative path, so i just get the folder name rather than the absolute path?

please help.

cheers

dave

Thijs Koerselman's icon

path-> [thispatcher]

use [sprintf %ssubfolder/subsubfolder] to concat the rest of the folderpath.

best, thijs

P_Petrowiek's icon

ok i might missunderstand something and in that case please excuse me in
advance.
Did you have a look at the objects relativepath absolutepath and filepath ?

Sorry if my answer if too simple, maybe i got something wrong.
HTH.
Seb.T

dave walker's icon

yeh i have,

but the object relativepath only works for within the max application program. so im having a bit of difficulty trying to just get a relative path from the main folder.

any ideas?
dave

dave walker's icon

hi thijs,

here is what i have...sorry i couldn't figure out how/where to put in your suggested object

Max Patch
Copy patch and select New From Clipboard in Max.

Im trying just to get the relative path.

hope you can help?

cheers,
dave

lists@lowfrequency.or's icon

javascript is good for sorting this kind of thing out:

    appFilePath = "";

    post("path: " +this.patcher.filepath);

    var tmp = this.patcher.filepath.split("/");

    post("Filepath: "+ this.patcher.filepath + "n");

    if (tmp[tmp.length-1] != "MacOS") tmp.pop(); //remove patcher name

    for(var c=0; c
    {
        appFilePath += tmp[c] + "/";
    }

    newFilePath = appFilePath + "yourDirectory/";

Roman Thilenius's icon

you cant get relative paths that way.

if you have

/harddisk/maxmsp/searchpath/

and

/harddisk/file.txt

there is no relative path between max runtime
and the file because it would include going
2 levels up.
if you want to build an app which uses a "samples"
folder relative beside the app, you could
incluide a "samples" folder in your search path
during programming.

John J.A. Jannone's icon

That javascript is missing a bit:

appFilePath = "";
    //post("path: " +this.patcher.filepath);
     var tmp = this.patcher.filepath.split("/");
     //post("Filepath: "+  this.patcher.filepath + "n");
     if (tmp[tmp.length-1] != "MacOS")  tmp.pop();  //remove patcher name
     for(var c=0; c<tmp.length-1; c++)
     {
        appFilePath += tmp[c] + "/";
    }
     newFilePath = appFilePath + "data/";
John J.A. Jannone's icon

Here's an example in situ:

Max Patch
Copy patch and select New From Clipboard in Max.
function makepath(fname)
{
appFilePath = "";
     //post("path: " +this.patcher.filepath);
     var tmp = this.patcher.filepath.split("/");
     //post("Filepath: "+  this.patcher.filepath + "n");
     if (tmp[tmp.length-1] != "MacOS")  tmp.pop();  //remove patcher name
     for(var c=0; c<tmp.length-1; c++)
     {
        appFilePath += tmp[c] + "/";
    }
     newFilePath = appFilePath + "data/" + fname;
     outlet (0,newFilePath);
 }