Bug 438562 - A space at the end of a filename leads to erroneous importation of meta-data
Summary: A space at the end of a filename leads to erroneous importation of meta-data
Status: RESOLVED FIXED
Alias: None
Product: kid3
Classification: Applications
Component: general (show other bugs)
Version: 3.8.x
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Urs Fleisch
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-06-13 16:44 UTC by Glop
Modified: 2021-10-03 18:43 UTC (History)
0 users

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Glop 2021-06-13 16:44:25 UTC
SUMMARY
A file containing a space at the end of its name and before the last dot and extension leads to errors when importing tags from filename

STEPS TO REPRODUCE
1. Open a directory with music files
2. One of those files is named as "filename .ext" rather than "filename.ext"
3. Set the import filter as "%{discnumber}.%{track} %{title}"
4. Import the tags using the Label 2 button.

OBSERVED RESULT
- The Title field contains the track number and the title
- The Artist field contains the parent/parent directory of the files
- The Album field contains the parent directory
- The Tracknumber field contains the disc number
- Other fields are empty, as expected

EXPECTED RESULT
- The Title field should only contain the title of the track
- The Artist and Album fields should be empty

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 5.22.0
KDE Frameworks Version: 5.82.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
Comment 1 Urs Fleisch 2021-06-20 17:10:02 UTC
First, I am not sure if I understand correctly what you mean with "import filter" and "Label 2" button, but I assume that the "import filter" is the "Format: <arrow down>" control and the "Label 2" button the "Tag 2" button at the right side of this control in the main section of the GUI.

You have a format of "%{discnumber}.%{track} %{title}" but a file name "filename .ext", which is missing the discnumber and track part. Let's assume that you have a file name "2.01 filename .ext" then you expect the tag frames to be set as Title="filename ", Track Number="1", Disc Number="2". To get this, you have to use a custom regular expressions in the format, e.g.

%{discnumber}(\d{1,4}).%{track}(\d{1,4}) %{title}([^-_\./ ](?:[^/]*[^-_/])?)

This is a modification of the standard regular expression for your format

%{discnumber}(\d{1,4}).%{track}(\d{1,4}) %{title}([^-_\./ ](?:[^/]*[^-_/ ])?)

with the difference that it is accepting a space at the end. You have to use custom regular expressions if you do not want the standard behavior.
Comment 2 Glop 2021-06-21 18:57:23 UTC
(In reply to Urs Fleisch from comment #1)
> First, I am not sure if I understand correctly what you mean with "import
> filter" and "Label 2" button, but I assume that the "import filter" is the
> "Format: <arrow down>" control and the "Label 2" button the "Tag 2" button
> at the right side of this control in the main section of the GUI.
Yes, that's it.
> 
> You have a format of "%{discnumber}.%{track} %{title}" but a file name
> "filename .ext", which is missing the discnumber and track part. Let's

I meant the discnumber and track informations are part of "filename .ext".

> assume that you have a file name "2.01 filename .ext" then you expect the
> tag frames to be set as Title="filename ", Track Number="1", Disc
> Number="2". To get this, you have to use a custom regular expressions in the
> format, e.g.
> 
> %{discnumber}(\d{1,4}).%{track}(\d{1,4}) %{title}([^-_\./ ](?:[^/]*[^-_/])?)
> 
> This is a modification of the standard regular expression for your format
> 
> %{discnumber}(\d{1,4}).%{track}(\d{1,4}) %{title}([^-_\./ ](?:[^/]*[^-_/ ])?)
> 
> with the difference that it is accepting a space at the end. You have to use
> custom regular expressions if you do not want the standard behavior.

Perhaps the custom regular expression should become standard to avoid getting scrambled tags.
Comment 3 Urs Fleisch 2021-10-03 18:43:26 UTC
Git commit efaf8e69552edf364e9b4881e7f0c5503e61eb55 by Urs Fleisch.
Committed on 03/10/2021 at 18:42.
Pushed by ufleisch into branch 'master'.

Get tags from file names with spaces before the extension

M  +5    -0    src/core/tags/taggedfile.cpp

https://invent.kde.org/multimedia/kid3/commit/efaf8e69552edf364e9b4881e7f0c5503e61eb55