If the input is a file, then use the dirname