Because of the viscoelasticity of the subsurface medium, seismic waves will inherently attenuate during propagation, which lowers the resolution of the acquired seismic records. Inverse-Q filtering, as a typical approach to compensating for seismic attenuation, can efficiently recover high-resolution seismic data from attenuation. Whereas most efforts are focused on compensating for high-frequency energy and improving the stability of amplitude compensation by inverse-Q filtering, low-frequency leakage may occur as the high-frequency component is boosted. In this article, we propose a compensation scheme that promotes the preservation of low-frequency energy in the seismic data. We constructed an adaptive shaping operator based on spectral-shaping regularization by tailoring the frequency spectra of the seismic data. We then performed inverse-Q filtering in an inversion scheme. This data-driven shaping operator can regularize and balance the spectral-energy distribution for the compensated records and can maintain the low-frequency ratio by constraining the overcompensation for high-frequency energy. Synthetic tests and applications on prestack common-reflection-point gathers indicated that the proposed method can preserve the relative energy of low-frequency components while fulfilling stable high-frequency compensation.