Spectroscopy of nuclear resonances offers a wide range of applications due to the remarkable energy resolution afforded by their narrow linewidths. However, progress toward higher resolution is inhibited at modern x-ray sources because they deliver only a tiny fraction of the photons on resonance, with the remainder contributing to an off-resonant background. We devised an experimental setup that uses the fast mechanical motion of a resonant target to manipulate the spectrum of a given x-ray pulse and to redistribute off-resonant spectral intensity onto the resonance. As a consequence, the resonant pulse brilliance is increased while the off-resonant background is reduced. Because our method is compatible with existing and upcoming pulsed x-ray sources, we anticipate that this approach will find applications that require ultranarrow x-ray resonances.