Get the dirname more reliably

%:p does not get the absolute path of a file that doesn't exist.