p: use dirname and basename to get the base of the path