Preparation of halogenated hydrocarbons by replacement by halogens of halogen atoms by other halogen atoms