Motor proteins and other biological machines are highly efficient at converting energy into directed motion and driving chemical systems away from thermodynamic equilibrium. But even though these biological structures have inspired the design of many molecules that mimic aspects of their behaviour, artificial nanomachine systems operate almost exclusively by moving towards thermodynamic equilibrium, not away from it. Here we show that information about the location of a macrocycle in a rotaxane-a molecular ring threaded onto a molecular axle-can be used, on the input of light energy, to alter the kinetics of the shuttling of the macrocycle between two compartments on the axle. For an ensemble of such molecular machines, the macrocycle distribution is directionally driven away from its equilibrium value without ever changing the relative binding affinities of the ring for the different parts of the axle. The selective transport of particles between two compartments by brownian motion in this way bears similarities to the hypothetical task performed without an energy input by a 'demon' in Maxwell's famous thought experiment. Our observations demonstrate that synthetic molecular machines can operate by an information ratchet mechanism, in which knowledge of a particle's position is used to control its transport away from equilibrium.