Bug 507221 - %{tracknumber} extracts 2 digits
Summary: %{tracknumber} extracts 2 digits
Status: RESOLVED NOT A BUG
Alias: None
Product: kid3
Classification: Applications
Component: general (other bugs)
Version First Reported In: 3.9.x
Platform: Debian testing Linux
: NOR normal
Target Milestone: ---
Assignee: Urs Fleisch
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-07-19 09:37 UTC by Christian Weiske
Modified: 2025-07-19 14:45 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Weiske 2025-07-19 09:37:55 UTC
SUMMARY
Generating tags from the filename "1DasGespensterschloss.mp3" with format "%{tracknumber}%{title}" leads to track number "1D" and title "asGespensterschloss".
The format help tooltip says that "%{tracknumber}" extracts a single digit.

STEPS TO REPRODUCE
1. Have a file named "1DasGespensterschloss.mp3"
2. Set "Format <arrow down>" to "%{tracknumber}%{title}"
3. Click "to: tag 2"

OBSERVED RESULT
- Track number is "1D" although it should be "1"
- Title is "asGespensterschloss" although it should be "DasGespensterschloss"

EXPECTED RESULT
- Track number should be "1"
- Title should be "DasGespensterschloss"

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: kid3-qt 3.9.6 on Debian testing (nearly Debian 13)
KDE Plasma Version: none
KDE Frameworks Version: none
Qt Version: 6.8.2

ADDITIONAL INFORMATION
Using "%T%{title}" does not work at all, although the tooltip help says that "%T" is equivalent to "%{tracknumber}".
Comment 1 Urs Fleisch 2025-07-19 14:36:44 UTC
If you use simple format codes such as "%{tracknumber}%{title}", Kid3 will try to create a regular expression from it which should work in most cases. In this case, the regular expression would be "([A-Za-z]?\d+[A-Za-z]?)([^-_\./ ](?:[^/]*[^-_/ ])?)", which looks a bit complicated, but as I said, is thought to catch most cases, for the track number, also "vinyl numbers" such as "1A" would be supported. Unfortunately, your case is a bit special and not covered by this general regular expression (and frankly, having no separator is a bit weird because there might be tracks where the title starts with a digit and the track number has more than one digit, so if you want to avoid spaces in your file names I would rather replace them by underscores then removing them). For special cases like yours, you can set the regular expression yourself, the corresponding paragraph in the handbook starts with "Internally, a regular expression". Thus, in your case, you could use the format

"%{track}(\d+)%{title}([^/]+)"

, which will yield the expected results.
Comment 2 Christian Weiske 2025-07-19 14:45:46 UTC
Thank you for the explanation.

I did not create the file names myself but rather got them when downloading them from the internet[1], and with missing meta data I wanted to use kid3 to at least get a first set of meta data from the file names.

[1] https://web.archive.org/web/20250121160302/http://fragezeichen.neuvertonung.de/