Large-eddy simulations (LES) of the atmospheric boundary layer (ABL) require the specification of a turbulent inflow condition with appropriate turbulence intensities and length scales. When using a synthetic turbulence generator, the statistics obtained downstream of the inlet might deviate considerably from the intended values. In the present work we propose a fully automated approach to modify the input parameters for the turbulence generator such that the desired turbulence statistics are obtained at the downstream location of interest. The method employs a gradient-based optimization in combination with the divergence-free version of the digital filter method developed by Xie and Castro [1, 2]. A sensitivity analysis showed that the spanwise and vertical Reynolds stresses and length scales are the most influential input parameters. Hence, the optimization adjusts these parameters until the desired turbulence statistics are obtained downstream in the domain. The results demonstrate the promising capabilities of the method: the mean velocity profile is correctly maintained using an appropriate wall function, while the optimization results in Reynolds stresses, integral length-scales and turbulence spectra that compare well to ABL wind tunnel measurements.