https://bugs.kde.org/show_bug.cgi?id=462585

--- Comment #1 from Urs Fleisch <uflei...@users.sourceforge.net> ---
Let's take for example a file named "02a Story.opus". If you open it with
kid3-qt (which shares the configuration with kid3-cli which is used in your
case), and click "To: Tag 2", nothing happens. The reason is that the format,
which is in the control "Format: <arrow down>" at the left of the "To: Tag 2"
button, is "%{artist} - %{album}/%{track} %{title}", and this will be
transformed into a regular expression containing "(\d{1,4})" to capture the
track. For details, look into the handbook at
https://docs.kde.org/trunk5/en/kid3/kid3/commands.html#file, the section
starting with "Internally, a regular expression". Since "\d{1,4}" only matches
one to four digits, you will have to change it or add a new format which
explicitly sets the regular expression captures, e.g.

%{artist}([^-_\\./ ](?:[^/]*[^-_/ ])?) - %{album}([^-_\\./ ](?:[^/]*[^-_/
])?)/%{track}([A-Za-z]?\d+[A-Za-z]?) %{title}([^-_\\./ ](?:[^/]*[^-_/ ])?)

You can change the existing format in the control, or you can add a new one in
"Tag from filename..." in the "Format" section of the "Files" tab in the
settings, and then select this format in the "Format: <arrow down>" combo box.
Note that this format only matches, if the tracks are in a folder with format
"artist - album". If this is not the case, you could use only the part with
track and title:

/%{track}([A-Za-z]?\d+[A-Za-z]?) %{title}([^-_\\./ ](?:[^/]*[^-_/ ])?)

The regular expression still looks a bit complicated, but tries to be as
specific as possible, here it expects tracks to contain a number which can have
a leading or trailing digit.

In your example, you have a file name "b01.opus", which does not contain a
title. So you could remove the part with the title or make it optional:

/%{track}([A-Za-z]?\d+[A-Za-z]?)(?: %{title}([^-_\\./ ](?:[^/]*[^-_/ ])?))?

As kid3-qt and kid3-cli share their configuration, you can now use kid3-cli and
"totag" should work as expected (you could also change the configuration from
kid3-cli with the config command, but that is a bit more complicated).

$ kid3-cli -c totag 02b.opus
$ kid3-cli -c get 02b.opus
File: Opus 1 114 kbps 48000 Hz 2 Channels
  Name: 02b.opus
Tag 2: Vorbis
  Track Number  02b
  Encoder       opusenc from opus-tools 0.1.2

With kid3-cli you can explicitly give the format, which you did in your
example, so you just have to explicitly give the regular expression capture (if
you do not want to change to format in the configuration).

$ kid3-cli -c "totag '/%{track}([A-Za-z]?\d+[A-Za-z]?)'" 02b.opus
$ kid3-cli -c get 02b.opus
File: Opus 1 114 kbps 48000 Hz 2 Channels
  Name: 02b.opus
Tag 2: Vorbis
  Track Number  02b
  Encoder       opusenc from opus-tools 0.1.2

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to