From a35e9be6697a5a3956a9b5128c16a276dceac73d Mon Sep 17 00:00:00 2001 From: Tobias Ellinghaus Date: Thu, 11 Dec 2014 11:03:33 +0100 Subject: [PATCH] Add a script to delete tags that are too long --- official/delete_long_tags.lua | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 official/delete_long_tags.lua diff --git a/official/delete_long_tags.lua b/official/delete_long_tags.lua new file mode 100644 index 0000000..a4e41c1 --- /dev/null +++ b/official/delete_long_tags.lua @@ -0,0 +1,34 @@ +--[[ + This file is part of darktable, + copyright (c) 2014 Tobias Ellinghaus + + darktable is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + darktable is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with darktable. If not, see . +]] + +local dt = require "darktable" + +dt.preferences.register("delete_long_tags", "length", "integer", + "maximum length of tags to keep", + "tags longer than this get deleted on start", + 666, 0, 65536) + +local max_length = dt.preferences.read("delete_long_tags", "length", "integer") + +for _,t in ipairs(dt.tags) do + local len = #t.name + if len > max_length then + print("deleting tag `"..t.name.."' (length: "..len..")") + t:delete() + end +end