diff --git a/imgrate.py b/imgrate.py index 67ab8cf..0ea5d90 100755 --- a/imgrate.py +++ b/imgrate.py @@ -49,9 +49,12 @@ class imgrate: if __name__ == '__main__': + from os import remove + def parse_arguments(): ap = ArgumentParser() ap.add_argument('images', type=str, nargs='+', help='') + ap.add_argument('-d', '--delete', action='store_true', help='Delete all but the best quality image.') return ap.parse_args() @@ -63,4 +66,8 @@ if __name__ == '__main__': maxmark = '*' if rating == maximum and len(ratings) > 1 else ' ' print('{}imgrate("{}") = {}'.format(maxmark, rating, ratings[rating])) + if args.delete: + [remove(image) for image in ratings if image != maximum] + + run(parse_arguments())