Dynamic diffraction gratings are optical devices that allow for non-mechanical, non-contact and remote on-demand control, and have garnered significant interest in optical encryption. Azobenzene materials are ideal materials for developing dynamic gratings owing to the advantages of fast photo isomerization and good reversibility. It is still challenging to precisely fabricate ordered periodic gratings on the surfaces of azobenzene materials. Here, controllable dynamic grating patterns were successfully fabricated by mask exposure and solvent engineering on azobenzene polyamide acid (PAA-Azo)-solvent system. The movement and mass migration of polymer chains can be regulated by modulating the intermolecular hydrogen bonding and free volume based on different solvents and solvent contents within the system, resulting in the formation of surface gratings with customizable morphology and light-splitting ability. Finally, by regulating the periodicity and amplitude of gratings, colorful dynamic patterns were obtained to monitor the expiration of light-sensitive and short shelf-life products, based on the azobenzene polyamide acid (PAA-Azo)-solvent system. This work provides a new and simple approach for controllable preparation of high-regularity and high-performance dynamic gratings.