Bug 492660 - Renaming multiple files removes file extension for unknown file types
Summary: Renaming multiple files removes file extension for unknown file types
Status: ASSIGNED
Alias: None
Product: dolphin
Classification: Applications
Component: general (other bugs)
Version First Reported In: 24.08.0
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Dolphin Bug Assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-09-04 19:42 UTC by Tarulia
Modified: 2025-03-21 06:27 UTC (History)
4 users (show)

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 Tarulia 2024-09-04 19:42:01 UTC
SUMMARY
While renaming some of my media files I noticed that on one specific combination of files, Dolphin would remove the file extension on one of the files. I can consistently reproduce this with test files, but on different file types it seems fine. It *might* have to do with unknown/unassigned file extensions.

STEPS TO REPRODUCE
1. touch file.idx file.sub
2. Select both files in Dolphin
3. F2 or Right-Click -> Rename
4. Enter a new name, e.g. "test" (no # since there's no counter required)
5. Hit Rename

OBSERVED RESULT
$ ls
test
test.sub

EXPECTED RESULT
Dolphin should keep the file extension in all cases, i.e. correct would be:
$ ls
test.idx
test.sub

SOFTWARE/OS VERSIONS
Operating System: Fedora Linux 40 (KDE Spin)
KDE Plasma Version: 6.1.4
KDE Frameworks Version: 6.5.0
Qt Version: 6.7.2

ADDITIONAL INFORMATION
I tried the same with a couple other file extensions:
mkv & mp4 -> fine
log & txt -> fine
jpg & gif
ext1 & ext2 -> would not allow me to rename without adding a counter, when adding a counter it removes both file extensions
idx & sub (see above) -> idx is an "unknown" filetype i.e. right click brings up the "Open With…" option, while the sub file is recognised as a text file and brings up "Open With KWrite"
Comment 1 Justin Zobel 2025-02-08 01:38:12 UTC
Confirmed with Dolphin 24.12.1 on:
Operating System: Solus 4.7
KDE Plasma Version: 6.2.5
KDE Frameworks Version: 6.10.0
Qt Version: 6.8.1
Kernel Version: 6.12.9-312.current (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 PRO 4750U with Radeon Graphics
Memory: 29.1 GiB of RAM
Graphics Processor: AMD Radeon Graphics
Comment 2 xust 2025-03-19 07:49:46 UTC
rename files which have same suffix `.idx` also makes file lost it's suffix.
seems like the `.idx` cannot be correctly batch renamed.
seems like a Qt bug, or the mime database doesn't contains the `.idx` suffix.
tested with minimal qt demo:
#include <QCoreApplication>
#include <QMimeData>
#include <QMimeDatabase>
#include <QDebug>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    QMimeDatabase db;
    const QString extension = db.suffixForFileName("/home/debian/Downloads/file.idx");
    qDebug() << "######  " << extension; // output an empty string
    return 0;
}
Comment 3 xust 2025-03-19 08:55:45 UTC
also, this is not a bug of qt, qt reads all mime from system, the idx is not included in, see:

 debian@debian  /usr/share/mime/text  cat x-mpsub.xml                                                                                                ✔  959  16:53:10
<?xml version="1.0" encoding="utf-8"?>
<mime-type xmlns="http://www.freedesktop.org/standards/shared-mime-info" type="text/x-mpsub">
  <!--Created automatically by update-mime-database. DO NOT EDIT!-->
  <comment>MPlayer subtitles</comment>
  <comment xml:lang="uk">субтитри MPlayer</comment>
  <comment xml:lang="sv">MPlayer-undertexter</comment>
  <comment xml:lang="ru">Субтитры MPlayer</comment>
  <comment xml:lang="pl">Napisy MPlayer</comment>
  <comment xml:lang="es">subtítulos de MPlayer</comment>
  <comment xml:lang="de">MPlayer-Untertitel</comment>
  <sub-class-of type="text/plain"/>
  <glob pattern="*.sub"/>
</mime-type>

so you can install the mimetype description file or create a file yourself to solve this issue.
Comment 4 xust 2025-03-19 09:00:26 UTC
(In reply to xust from comment #3)
> also, this is not a bug of qt, qt reads all mime from system, the idx is not
> included in, see:
> 
>  debian@debian  /usr/share/mime/text  cat x-mpsub.xml                     
>  ✔  959  16:53:10
> <?xml version="1.0" encoding="utf-8"?>
> <mime-type xmlns="http://www.freedesktop.org/standards/shared-mime-info"
> type="text/x-mpsub">
>   <!--Created automatically by update-mime-database. DO NOT EDIT!-->
>   <comment>MPlayer subtitles</comment>
>   <comment xml:lang="uk">субтитри MPlayer</comment>
>   <comment xml:lang="sv">MPlayer-undertexter</comment>
>   <comment xml:lang="ru">Субтитры MPlayer</comment>
>   <comment xml:lang="pl">Napisy MPlayer</comment>
>   <comment xml:lang="es">subtítulos de MPlayer</comment>
>   <comment xml:lang="de">MPlayer-Untertitel</comment>
>   <sub-class-of type="text/plain"/>
>   <glob pattern="*.sub"/>
> </mime-type>
> 
> so you can install the mimetype description file or create a file yourself
> to solve this issue.

but I think kio could do some workaround? such as if suffix obtained from qmimedatabase is empty, do split by dot, and use the last part as suffix? only if `fullName.split('.').count() >=2`
Comment 5 Tarulia 2025-03-19 09:04:41 UTC
Well that raises 2 questions:

1. Should this rely on MIME-types at all or simply see everything after the last dot as the file-extension (possibly with a switch?)
2. What's the upstream of those MIME-type files so the extension can be added there? Is it https://gitlab.freedesktop.org/xdg/shared-mime-info/-/releases ?
Comment 6 xust 2025-03-19 09:10:57 UTC
(In reply to Tarulia from comment #5)
> Well that raises 2 questions:
> 
> 1. Should this rely on MIME-types at all or simply see everything after the
> last dot as the file-extension (possibly with a switch?)
> 2. What's the upstream of those MIME-type files so the extension can be
> added there? Is it
> https://gitlab.freedesktop.org/xdg/shared-mime-info/-/releases ?

1. I have the same idea with you, as I suggeted to KIO in my comments, and I'll make a pr see if KIO accept.
2. I'm not clear about this.
Comment 7 Bug Janitor Service 2025-03-19 09:48:19 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/1846
Comment 8 Méven 2025-03-21 06:27:04 UTC
(In reply to xust from comment #2)
> rename files which have same suffix `.idx` also makes file lost it's suffix.
> seems like the `.idx` cannot be correctly batch renamed.
> seems like a Qt bug, or the mime database doesn't contains the `.idx` suffix.

Qt and KDE software use standard shared mime database https://gitlab.freedesktop.org/xdg/shared-mime-info
If an extension needs to be recoginsed, that's where it needs to be fixed.