Use backticks for command substitution, and quote dirname's arguments