diff --git a/beets/ui/commands.py b/beets/ui/commands.py index 3e3acb7c3..176cf9218 100644 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -1330,13 +1330,7 @@ def modify_items(lib, mods, dels, query, write, move, album, confirm): .format(len(objs), 'album' if album else 'item')) changed = set() for obj in objs: - obj.update(mods) - for field in dels: - try: - del obj[field] - except KeyError: - pass - if ui.show_model_changes(obj): + if print_modify_item(obj, mods, dels): changed.add(obj) # Still something to do? @@ -1364,6 +1358,21 @@ def modify_items(lib, mods, dels, query, write, move, album, confirm): obj.try_sync(write, move) +def print_modify_item(obj, mods, dels): + """Print the modifications to an item + and return False if no changes were made + mods: modifications + dels: fields to delete + """ + obj.update(mods) + for field in dels: + try: + del obj[field] + except KeyError: + pass + return ui.show_model_changes(obj) + + def modify_parse_args(args): """Split the arguments for the modify subcommand into query parts, assignments (field=value), and deletions (field!). Returns the result as