Is there a method to remove unused Tags please?

Hi All. I currently use LIghtroom and have quite a few Images ~90K or so. For various reasons I am now looking to move away from LIghtroom and I have started looking at Darktable Windows version. After looking at several videos and playing around with a few images, it is starting to make some sense :slight_smile: and looks to be pretty powerful. However I do use a lot of keywords in LIghtroom and some of my existing ones need to be cleaned up and re-categorised so migrating to Darktable would be a good excuse to do this, but I cannot see a way to delete unused Tags from the Tagging list. I tried the export and import without much success so any tips at all would be helpful please? - Thanks

1 Like

There is a very nice usermanual which says you can delete tags. https://www.darktable.org/usermanual/en/tagging.html#tagging

Does this work for you. The program is spelled darktable, all in lower case. See
faq | darktable

1 Like

What? A user’s manual?

Joke apart, you also have a script in the source tree to delete all ununsed tags:

1 Like

The shell script won’t work on Windows out of the box, as we don’t distribute shell scripts in the windows installer, because there is no shell normally on Windows to run them.

Pascal, Peter. Thanks for the replies. I shall have to see if there is some other workaround for the problem. I guess the way forward would be to clean up the images in chunks on Lightroom before porting over and do it over a period of time rather than in one go.

Again, thanks for your help, it was useful and saved me hunting for a method

Steve

If you can figure out how to use Lua scripts in darktable then this script might do what you want:

local dt = require "darktable"

-- deleting while iterating the tags list seems to break the iterator!
local unused_tags = {}

for _, t in ipairs(dt.tags) do
  if #t == 0 then
    table.insert(unused_tags, t.name)
  end
end

for _,name in pairs(unused_tags) do
  print("deleting tag `" .. name .. "'")
  tag = dt.tags.find(name)
  tag:delete()
end
2 Likes

Appreciate the script Houz. thank you.

Steve

Unused tags? Ah, sorry might have been to early in the morning. :sleeping:

If you import your images from LR and darktable reads the tags from the LR xmp, there should not be any unused tags. Right?

So, if you only played a bit with darktable and there are only a few images in your database, you can delete the library.db and start from scrath.

If you want to reorganize the tags in darktable this LUA script might be interesting as well:

The script from @houz might be a nice addition to this!

Hiya Pk5, no worries :grin:, appreciate the help. I shall continue with testing and see how it pans out. Good to know about the library.db as It will be good to trash and start again a few times until I work out a migration method

Steve

@houz
Please push it to the lua-scripts.

Done.

Oh, the script on github is different from what is proposed above. What is the reason?

The LUA API is not clear to me in the point of how unused tags can be found:

https://www.darktable.org/lua-api/index.html#darktable_tags

From that part of your script from above I drew the conclusion that the numeric entry is the number of images the tag is attached to? :thinking:

Apart from some boiler plate (copyright and version check) it should be identical.

Finding the number of images is the same as checking the length of the image list, which is done with the # operator.

1 Like

Thanks!

Each existing tag has a numeric entry in the tags table - use ipairs to iterate over them.

So the numeric entry is the number of images the tag is attached to.

Each existing tag has a numeric entry in the tags table representing the number of images the tag is attached too - use ipairs to iterate over them.

Would be a description in the LUA api like that be clearer?

I have no idea what that sentence in the API docs is supposed to mean. However, the # operator is nothing darktable specific, it’s standard Lua. So I wouldn’t put that into the API docs.

1 Like