Generalize this script and update README.