How to hide files with specfic file extension in dolphin?

Some software that i use like Krita and blender make backup files. Krita’s backup file have the ~ (tilde) chararcter so they get a special file icon which makes them distinguishable from normal files. But blender saves the backup by suffixing the number 1 after the file extension for example a “project.blend” will have a corresponding “project.blend1” file as a backup file. These two file stay side by side and often it leads to mistakes like opening and working on the backup file. When you realise you have been working on the backup file and not the original one it will be too late.

So is there a way in dolphin to hide files of specific extensions in addition to the dot files. I know there is a trick like “.hidden” but as far as I know it works in the current directory and is not system wide.

In the next Dolphin release, this will in fact be done automatically. See 3212 – Option to hide backup files as well as dotfiles?.

3 Likes

Wow! that is great to hear.

I read the bug report and the merge request. I am not a dev so Asking this to confirm. Does it only hide the files with trash mimetype or does it allow users to specify via regex or any other method to define what file type should be hidden?

It looks like the set of files to hide is hardcoded internally, not user-configurable.

Then sadly it is not the request I have made here. I would request for a user configurable thing. For example in my use case mentioned above, i want to hide files with “.blend1” extension I do not think blender adds any mimetype for this. I also saw in one comment of the bug report stating that some user would want to hide the pycache folder or say some user might want to hide the files ending with something.bak. So it would be good to get a user configurable system. may be a way to put regex or simlpe a list.

Yeah, perhaps that feature can be added in the future.

However there may be a way for Blender and other apps to support this themselves. The code says that now files with the mime type of application/x-trash get auto-hidden. If .blend1 files already have that mime type (you can check with file --mime-type [path to the file in question]), then it will work out of the box. If not, it might be worth a request for the Blender people that they give it this mime type.

I checked the mimetype and it is “application/x-blender”.

I do not have any problem with requesting this with blender people, I will try. I feel that they will not consider this file as a different mimetype, as far as I know these are versions and not backups and there can be multiple file like - blend1, blend2 and blend3 etc. But I may be wrong.

However there may be other such files which are not backup files by strictest sense and these would be good if hidden for some users’ workflow. Blender is just one example, what if there are some more files like these for other software?

It’s a reasonable question.

In a sense this is sort of about the relationship between apps and the platforms they run on; who owes what to whom?

On macOS, Apple would roll this out and apps shipping on macOS would go out of their way to support it. Apps that don’t would field complaints from their users.

In KDE land, we’re a minority of a minority, so we don’t generally expect 3rd-party apps to care about us. We can consider our responsibility to react to them, or even to offer users tools to make this work themselves–which is what you and the original bug report are requesting.

I’m not against doing so. But sometimes I think back to my time in the Apple world a bit wistfully, and wish we could get apps to care about us a bit more!

3 Likes

What do you mean with “not system wide”?

If you change the MIME type doesn’t that also change other properties like file association, Icon and so on?

sounds like what blender is really doing would better be defined as version control… it’s just not a very good one.

rather than rely on their lame “tack a number on the end of filename” trick, maybe come up with your own version control scheme and ask them to implement it (or something similar).

The question was not only about blender file nor it was about the technique blender uses for versioning or anything else. The question was about dolphin and whether it is possible to hide certain specific file extension. The file extension can be blend files or anything the user wants to hide from view. So please do not take the debate on a different tangent and push it on other projects. This is a KDE forum and we are not here to discuss the choices of blender or any other non KDE software. Ignore the blender name and answer if this is possible or how to achieve it.

This sounds more like “patches welcome” phrase said to a non coding person, despite the “kde developer” title besides my user name I am not a programmer neither do I intend to be one. If non programmers are not allowed to suggest or ask questions without knowing to code their own version control then KDE should specify this point with a pinned post on the front page of this forum.

It’s a bit strange that backup files are application/x-trash, not application/x-backup.

BTW, just found that Dolphin has been supporting “.hidden” for over a decade. (246260 – KDirLister - kdelibs/kio - should respect .hidden files, an at-least-de-facto standard that gnome respects) But it only affects the current dir, doesn’t allow globs, and doesn’t have any UI.

OTOH, the TUI file manager I use, Broot, hides .gitignore files by default. In addition, the shell programs ripgrep and fd also supports .ignore files, which has the same format as .gitignore, but doesn’t affect git.

Perhaps Dolphin could (have an option to) hide .gitignore and .ignore files too. Compared to a Dolphin-specific setting, this is supported by more tools, and is more powerful (globs, directory-specific settings).

1 Like

extremly quick - and maybe false - approach:

<?xml version="1.0" encoding="utf-8"?>
<mime-type xmlns="http://www.freedesktop.org/standards/shared-mime-info" type="application/x-trash">
  <!--Created automatically by update-mime-database. DO NOT EDIT!-->
  <comment>Blender scene (backups)</comment>
  <generic-icon name="application/x-blender"/>
  <glob pattern="*.blend1"/>
</mime-type>

maybe named: /usr/share/mime/application/x-blender-backup.xml

2 Likes

Thank you I will try this.

This is one solution for the blend1 files but do I need to make this for all the files I may need to be hidden in future. it will be cumbersome hence I think a setting or feature in dolphin would be good.

Thank you once again.

Also this can be stoed in ~/.local/share/mime/application too and the file association KCM in system settings allow to create new mimetypes too with a GUI

@chartmann solution didn’t work for me, but I modified it a bit, followed the Arch Wiki and found a solution that worked for me (although I am not certain if this is correct, so be careful if you try to replicate)

I created ~/.local/share/mime/packages/x-blender-backup.xml with the following text:

<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
    <mime-type type="application/x-trash">
        <comment>Blender scene (backups)</comment>
         <glob pattern="*.blend?*"/>
    </mime-type>
</mime-info>

Then I ran update-mime-database ~/.local/share/mime

refreshed Dolphin. The Result is that .blend1 .blend2 can be hidden, but .blend (without numbers) will not be. I assumed .blend without numbers shouldn’t be hidden because this is maybe the original and not a backup?

Since I am not a Blender user I cannot say if everything still works as expected. For example can you still open this in Blender?

Certainly interesting, gonna play with this a little bit more.

1 Like

awesome! i didn’t test anything. i’ve just grep’d and scribbled it down from the original blender mime info definition.

i think you already have your answer, i was just offering another idea.

take it how you will.

yes the .blend file is the original.

Thank you for both @chartmann and @Duha I will test this and report back. :+1:t4: :bouquet:

How do i use the “.hidden” file, what to put in the file? Do I need to refresh/reboot Dolphin?
Would be nice to use it to hide files with the “.torrent” ending/filetype?