querying patch name + path specifier to current folder

ericsinger's icon

Two questions:

1) Is there a way to get the name of a patch from within the patch? A 'path' message into [[thispatcher]] gives the path to the patch, but not the name of the patch itself.

2) For objects which write files based on a fully specified path (for example, 'write ' into [[pattrstorage]]), is there a way to specify the directory in which the patch resides? I know I can build this up from the path returned above, but I'm hoping for something akin to ~ (which specifies the user directory). For example ?/myfile, where ? is a specifier meaning the path in which the containing patch resides.

Christopher Dobrian's icon

In JavaScript the property 'this.patcher.filepath' contains the filename including the full path, and 'this.patcher.name' contains just the filename.

Michel's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Here a patch with js code I found in the forum

Save as NameFile.js :

function name ()
{
outlet (0,this.patcher.name);
}