Add a script to delete tags that are too long

This commit is contained in:
Tobias Ellinghaus
2014-12-11 11:03:33 +01:00
parent dab444ac65
commit a35e9be669

View File

@@ -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 <http://www.gnu.org/licenses/>.
]]
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