This is a simple abstraction that I have been using for a while to deal with relative paths in max, specially useful when you use hundreds of samples that you don't want to have on the same folder where your main patch lies.
So here is how it works:
I am assuming that you have your whole project inside a folder that is not in Max's search path. Ideally, in the main folder I would have the main patch, any additional abstractions that I need and a set of folders where all media files are stored. These in turn may be further organised in sub-folders, say a different sub-folder for each instrument that I sampled or for duration ranges, etc.
This media files might then be called from all sorts of objects like sfplay~, buffer~, etc.
So here is how my abstraction works.
You construct your message in the format: for example "open /firstsubfolder/secondsubfolder/myfile.wav"
you connect this message box to the sfolder abstraction and the output of it to whatever object you are sending sound to, i.e. sfplay~ in this case. That's it!
sfolder will generate the preceding part of the file path (including names with spaces) and format it into an absolute path that sfplay~ will be happy with.
There some things to keep in mind tho:
1.- A copy of sfolder must be placed in the top level of your project, along your main patch. That is, you cant drop it into the externals folder and just call it from within the patch as this would generate the path to the externals folder.
2.- The folder and file names of your project can NOT contain spaces. The message you are sending to sfolder is composed of two strings: The command (i.e. open, replace, load, etc.) and the relative path including the filename. If you have spaces in the name of your media files, the patch won't work.
3.- All the media files to be used must be in folders WITHIN your main project folder. This small abstraction won't find things god-knows-where in your harddrive.
The main disadvantage I see of sfolder is that you need to place it somewhere that you will remember and manually drop it into your top level folder using finder when you first start your project.
Any suggestions for improvements are welcome but I won't have time to do any changes for at least a month. Also, I haven't tried it in windows but if there is additional formatting needed for it to work I'm sure one of the forum gurus could solve it in a second, it is not a complicated patch at all.
Attached is a zip file that includes a top level folder with the sfolder and a test patch and a sufbolder with two sound files. Unzip this folder anywhere on your hard drive and move it all over the place, both files should play every time.