Skip to content

Commit

Permalink
Update changelog and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
nichobi committed Sep 29, 2024
1 parent 7836149 commit 3403a05
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
3 changes: 3 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ New features:
* Beets now uses ``platformdirs`` to determine the default music directory.
This location varies between systems -- for example, users can configure it
on Unix systems via ``user-dirs.dirs(5)``.
* :doc:`/plugins/substitute`: Allow the replacement string to use capture groups
from the match. It is thus possible to create more general rules, applying to
many different artists at once.

Bug fixes:

Expand Down
19 changes: 17 additions & 2 deletions docs/plugins/substitute.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,28 @@ the ``rewrite`` plugin modifies the metadata, this plugin does not.

Enable the ``substitute`` plugin (see :ref:`using-plugins`), then make a ``substitute:`` section in your config file to contain your rules.
Each rule consists of a case-insensitive regular expression pattern, and a
replacement value. For example, you might use:
replacement string. For example, you might use:

substitute:
.*jimi hendrix.*: Jimi Hendrix

The replacement can be an expression utilising the matched regex, allowing us
to create more general rules. Say for example, we want to sort all albums by
multiple artists into the directory of the first artist. We can thus capture
everything before the first ``,``, `` &`` or `` and``, and use this capture
group in the output, discarding the rest of the string.

substitute:
^(.*?)(,| &| and).*: \1

This would handle all the below cases in a single rule:

Bob Dylan and The Band -> Bob Dylan
Neil Young & Crazy Horse -> Neil Young
James Yorkston, Nina Persson & The Second Hand Orchestra -> James Yorkston


To apply the substitution, you have to call the function ``%substitute{}`` in the paths section. For example:

paths:
default: %substitute{$albumartist}/$year - $album%aunique{}/$track - $title

0 comments on commit 3403a05

Please sign in to comment.