use dirname instead of grepping for slash, which could be / or \