renames $dirname back to $path