Calculations of electronic and optical properties of solids at finite temperature including electronphonon interactions and quantum zero-point renormalization have enjoyed considerable progress during the past few years. Among the emerging methodologies in this area, we recently proposed a new approach to compute optical spectra at finite temperature including phonon-assisted quantum processes via a single supercell calculation [Zacharias and Giustino, Phys. Rev. B 94, 075125 (2016)]. In the present work we considerably expand the scope of our previous theory starting from a compact reciprocal space formulation, and we demonstrate that this improved approach provides accurate temperature-dependent band structures in three-dimensional and two-dimensional materials, using a special set of atomic displacements in a single supercell calculation. We also demonstrate that our special displacement reproduces the thermal ellipsoids obtained from X-ray crystallography, and yields accurate thermal averages of the mean-square atomic displacements. At a more fundamental level, we show that the special displacement represents an exact single-point approximant of an imaginary-time Feynman's path integral for the lattice dynamics. This enhanced version of the special displacement method enables non-perturbative, robust, and straightforward ab initio calculations of the electronic and optical properties of solids at finite temperature, and can easily be used as a post-processing step to any electronic structure code. To illustrate the capabilities of this method, we investigate the temperature-dependent band structures and atomic displacement parameters of prototypical nonpolar and polar semiconductors and of a prototypical two-dimensional semiconductor, namely Si, GaAs, and monolayer MoS2, and we obtain excellent agreement with previous calculations and experiments. Given its simplicity and numerical stability, the present development is suited for high-throughput calculations of band structures, quasiparticle corrections, optical spectra, and transport coefficients at finite temperature.