© 2015 Society for Industrial and Applied Mathematics. In this paper the evolution of a binary mixture in a thin-film geometry with a wall at the top and bottom is considered. By bringing the mixture into its miscibility gap so that no spinodal decomposition occurs in the bulk, a slight energetic bias of the walls toward each one of the constituents ensures the nucleation of thin boundary layers that grow until the constituents have moved into one of the two layers. These layers are separated by an interfacial region where the composition changes rapidly. Conditions that ensure the separation into two layers with a thin interfacial region are investigated based on a phase-field model. Using matched asymptotic expansions a corresponding sharp-interface problem for the location of the interface is established. It is then argued that this newly created two-layer system is not at its energetic minimum but destabilizes into a controlled self-replicating pattern of trapezoidal vertical stripes by minimizing the interfacial energy between the phases while conserving their area. A quantitative analysis of this mechanism is carried out via a thin-film model for the free interfaces, which is derived asymptotically from the sharp-interface model.