mirror of
https://github.com/beetbox/beets.git
synced 2025-12-14 20:43:41 +01:00
Add --always flag for write subcommand
Forces a write of tags to file even if the file's tags match the database. This is useful to force plugins that respond to write (e.g., Scrub and Zero) to run on those tags. This may also make the TODO comment in zero.py less important since creates a way to manually run the zero plugin on a file imported as-is.
This commit is contained in:
parent
d8c4be100d
commit
2ffd3e287f
2 changed files with 13 additions and 6 deletions
|
|
@ -1415,7 +1415,7 @@ default_commands.append(move_cmd)
|
|||
|
||||
# write: Write tags into files.
|
||||
|
||||
def write_items(lib, query, pretend):
|
||||
def write_items(lib, query, pretend, always):
|
||||
"""Write tag information from the database to the respective files
|
||||
in the filesystem.
|
||||
"""
|
||||
|
|
@ -1440,13 +1440,13 @@ def write_items(lib, query, pretend):
|
|||
|
||||
# Check for and display changes.
|
||||
changed = ui.show_model_changes(item, clean_item,
|
||||
library.Item._media_fields)
|
||||
if changed and not pretend:
|
||||
library.Item._media_fields, always)
|
||||
if (changed or always) and not pretend:
|
||||
item.try_write()
|
||||
|
||||
|
||||
def write_func(lib, opts, args):
|
||||
write_items(lib, decargs(args), opts.pretend)
|
||||
write_items(lib, decargs(args), opts.pretend, opts.always)
|
||||
|
||||
|
||||
write_cmd = ui.Subcommand('write', help='write tag information to files')
|
||||
|
|
@ -1454,6 +1454,10 @@ write_cmd.parser.add_option(
|
|||
'-p', '--pretend', action='store_true',
|
||||
help="show all changes but do nothing"
|
||||
)
|
||||
write_cmd.parser.add_option(
|
||||
'-a', '--always', action='store_true',
|
||||
help="write tags even if the existing tags match the database"
|
||||
)
|
||||
write_cmd.func = write_func
|
||||
default_commands.append(write_cmd)
|
||||
|
||||
|
|
|
|||
|
|
@ -284,7 +284,7 @@ write
|
|||
`````
|
||||
::
|
||||
|
||||
beet write [-p] [QUERY]
|
||||
beet write [-pa] [QUERY]
|
||||
|
||||
Write metadata from the database into files' tags.
|
||||
|
||||
|
|
@ -294,9 +294,12 @@ have the option of storing changes only in the database, leaving your files
|
|||
untouched. The ``write`` command lets you later change your mind and write the
|
||||
contents of the database into the files.
|
||||
|
||||
You can think of this command as the opposite of :ref:`update-cmd`.
|
||||
|
||||
The ``-p`` option previews metadata changes without actually applying them.
|
||||
|
||||
You can think of this command as the opposite of :ref:`update-cmd`.
|
||||
The ``-a`` 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.
|
||||
|
||||
|
||||
|
||||
.. _stats-cmd:
|
||||
|
|
|
|||
Loading…
Reference in a new issue