From 3c0d14ee39432705f9937ae4ac7a149d19ae4f1c Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Sat, 28 Mar 2015 18:35:20 +0100 Subject: improve 'rename' command --- movietool/__init__.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'movietool') diff --git a/movietool/__init__.py b/movietool/__init__.py index 02bbd3f..33a0a5a 100755 --- a/movietool/__init__.py +++ b/movietool/__init__.py @@ -459,18 +459,26 @@ def do_rename(args): if result["alternative_title"] != result["title"]: print(" a.k.a.: {}".format(result["alternative_title"])) try: - select = int(input("Choose: ")) + select = input("Choose: ") + if not re.match("^[0-9]+$", select): + select = None + break + else: + select = int(select) except ValueError: pass + if not select: + print("Skip {}".format(input_file)) + continue + filename = "{alternative_title} ({year}) #{imdb_id}".format(**results[select-1]) filename = substitute_filename(filename) if os.path.exists(input_file): - choice = input("Move '{}' -> '{}' ? [y/N]: ".format(input_file, filename)).lower() - if choice == "y": - os.mkdir(filename) - shutil.move(input_file, filename) + print("Move '{}' -> '{}'".format(input_file, filename)) + os.mkdir(filename) + shutil.move(input_file, filename) else: print("mkdir '{}'".format(filename)) os.mkdir(filename) -- cgit v1.2.1