Returns a dirname, ensuring no trailing directory separator.
DIRECTORY is a string, symbol, or a list.