quote directory name before passing to 'dirname'