Hmm, so it seems getToken doesn't handle multiple characters as token, which means my previous script may not always work.
There's also an easier way to get the full filepath without the "File:\\" part.
So, here's a better version, that I've also put into it's own function, for easier handling.
PHP Code:
String getParentFolderPath(String path) {
string parentpath = "";
// we make sure the input path is not empty and that the second to last character is not a colon.
// if the second to last character is a colon, it means the input is the root of the drive ( c:\ )
if (strlen(path) > 0 && strmid(strright(path, 2), 0, 1) != ":") {
// we must urlEncode the string, because we cannot search for a single backslash otherwise
path = urlEncode(path);
int i = strlen(path) - 1;
while (i > -1) {
// search for the last backslash ( %5C ) position.
// we urlDecode all text before that position.
// the parentpath will then be that decoded text.
if (strsearch(strright(path, strlen(path) - i), "%5C") > -1) {
parentpath = urlDecode(strleft(path, i));
break;
}
else
i--;
}
}
return parentpath;
}
Here's how you use it:
You need to add the following line where you declare your global variables:
PHP Code:
Function String getParentFolderPath(String path);
Then you can call the function wherever you want, like this:
PHP Code:
// get the complete path to the currently playing file.
string filepath = getPath(getPlayItemMetaDataString("filename"));
// get the parent folder path.
string parentpath = getParentFolderPath(filepath);
// this messagebox will show the parent folder path
messagebox(parentpath, "test", 0, "");