Get dirname from paths to avoid opening files

This will fix an issue I've encountered on Linux in particular where if the filename isn't stripped off, xdg-open will try opening the file, not the directory the file is in.