Skip to content

Commit 850540c

Browse files
committed
Merge pull request #906 from hkhanna/write-always-flag
Add --force flag for write subcommand
2 parents b31ad38 + 4944686 commit 850540c

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

beets/ui/commands.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,7 +1415,7 @@ def move_func(lib, opts, args):
14151415

14161416
# write: Write tags into files.
14171417

1418-
def write_items(lib, query, pretend):
1418+
def write_items(lib, query, pretend, force):
14191419
"""Write tag information from the database to the respective files
14201420
in the filesystem.
14211421
"""
@@ -1440,20 +1440,24 @@ def write_items(lib, query, pretend):
14401440

14411441
# Check for and display changes.
14421442
changed = ui.show_model_changes(item, clean_item,
1443-
library.Item._media_fields)
1444-
if changed and not pretend:
1443+
library.Item._media_fields, force)
1444+
if (changed or force) and not pretend:
14451445
item.try_write()
14461446

14471447

14481448
def write_func(lib, opts, args):
1449-
write_items(lib, decargs(args), opts.pretend)
1449+
write_items(lib, decargs(args), opts.pretend, opts.force)
14501450

14511451

14521452
write_cmd = ui.Subcommand('write', help='write tag information to files')
14531453
write_cmd.parser.add_option(
14541454
'-p', '--pretend', action='store_true',
14551455
help="show all changes but do nothing"
14561456
)
1457+
write_cmd.parser.add_option(
1458+
'-f', '--force', action='store_true',
1459+
help="write tags even if the existing tags match the database"
1460+
)
14571461
write_cmd.func = write_func
14581462
default_commands.append(write_cmd)
14591463

docs/reference/cli.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,19 +284,22 @@ write
284284
`````
285285
::
286286

287-
beet write [-p] [QUERY]
287+
beet write [-pf] [QUERY]
288288

289289
Write metadata from the database into files' tags.
290290

291291
When you make changes to the metadata stored in beets' library database
292292
(during import or with the :ref:`modify-cmd` command, for example), you often
293293
have the option of storing changes only in the database, leaving your files
294294
untouched. The ``write`` command lets you later change your mind and write the
295-
contents of the database into the files.
295+
contents of the database into the files. By default, this writes the changes only if there is a difference between the database and the tags in the file.
296+
297+
You can think of this command as the opposite of :ref:`update-cmd`.
296298

297299
The ``-p`` option previews metadata changes without actually applying them.
298300

299-
You can think of this command as the opposite of :ref:`update-cmd`.
301+
The ``-f`` option forces a write to the file, even if the file tags match the database. This is useful for making sure that enabled plugins that run on write (e.g., the Scrub and Zero plugins) are run on the file.
302+
300303

301304

302305
.. _stats-cmd:

0 commit comments

Comments
 (0)