We report on the selective fabrication of high-quality Sr2IrO4 and SrIrO3 epitaxial thin films from a single polycrystalline Sr2IrO4 target by pulsed laser deposition. Using a combination of X-ray diffraction and photoemission spectroscopy characterizations, we discover that within a relatively narrow range of substrate temperature, the oxygen partial pressure plays a critical role in the cation stoichiometric ratio of the films, and triggers the stabilization of different Ruddlesden-Popper (RP) phases. Resonant X-ray absorption spectroscopy measurements taken at the Ir L-edge and the O K-edge demonstrate the presence of strong spin-orbit coupling, and reveal the electronic and orbital structures of both compounds. These results suggest that in addition to the conventional thermodynamics consideration, higher members of the Srn+1IrnO3n+1 series can possibly be achieved by kinetic control away from the thermodynamic limit. These findings offer a new approach to the synthesis of ultra-thin films of the RP series of iridates and can be extended to other complex oxides with layered structure.