I like doing this using Word() with matrix to define the range of return (Word supports negative index)
Names Default To Here(1);
filepath = Convert File Path("$SAMPLE_DATA/Big Class.jmp", windows);
directory = Word([1 -2], filepath, "/\") || "\";
Show(filepath, directory);
If you don't need to have "/" or "\" at the end of your folder path, you can drop the || "\"
part.
-Jarmo