diff --git a/patacrep/songs/convert/__main__.py b/patacrep/songs/convert/__main__.py index 8e007418..a6766452 100644 --- a/patacrep/songs/convert/__main__.py +++ b/patacrep/songs/convert/__main__.py @@ -17,11 +17,14 @@ def __usage(): def yesno(prompt): while True: - answer = input("{} [yn] ".format(prompt)) - if answer.strip().lower() == "y": - return True - if answer.strip().lower() == "n": - return False + answer = input("{} [yn](folllow with * to remember) ".format(prompt)).strip().lower() + remember = (answer[-1] == "*") + if remember: + answer = answer[0:-1] + if answer == "y": + return True, remember + if answer == "n": + return False, remember def confirm(destname): return yesno("File '{}' already exist. Overwrite?".format(destname)) @@ -50,14 +53,16 @@ if __name__ == "__main__": ) sys.exit(1) + remember = False for file in song_files: song = song_parsers[source]("", file, DEFAULT_CONFIG) try: converted = song.render(dest) destname = "{}.{}".format(".".join(file.split(".")[:-1]), dest) - if os.path.exists(destname): - if not confirm(destname): - continue + if os.path.exists(destname) and not remember: + overwrite, remember = confirm(destname) + if not overwrite: + continue with open(destname, "w") as destfile: destfile.write(converted)