Skip to content

Commit

Permalink
select non-existing images
Browse files Browse the repository at this point in the history
  • Loading branch information
ddittmar committed Oct 28, 2023
1 parent 867c49b commit dc50d40
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ change_group_leader|Yes|LMW|Change which image leads group
[rename_images](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/rename_images)|Yes|LMW|Rename single or multiple images
[rename-tags](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/rename-tags)|Yes|LMW|Change a tag name
[RL_out_sharp](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/rl_out_sharp)|No|LW|Output sharpening using GMic (Richardson-Lucy algorithm)
[select_non_existing](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/select_non_existing)|Yes|LMW|Enable selection of non-existing images in the the currently worked on images
[select_untagged](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/select_untagged)|Yes|LMW|Enable selection of untagged images
[slideshowMusic](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/slideshowMusic)|No|L|Play music during a slideshow
[transfer_hierarchy](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/transfer_hierarchy)|Yes|LMW|Image move/copy preserving directory hierarchy
Expand Down
77 changes: 77 additions & 0 deletions contrib/select_non_existing.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
--[[
This file is part of darktable,
copyright (c) 2023 Dirk Dittmar
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/>.
]]
--[[
Enable selection of non-existing images in the the currently worked on images, e.g. the ones selected by the collection module.
]]

local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"

-- module name
local MODULE = "select_non_existing"

du.check_min_api_version("9.1.0", MODULE)

-- figure out the path separator
local PS = dt.configuration.running_os == "windows" and "\\" or "/"

local gettext = dt.gettext
gettext.bindtextdomain(MODULE, dt.configuration.config_dir..PS.."lua"..PS.."locale"..PS)

local function _(msgid)
return gettext.dgettext(MODULE, msgid)
end

local function stop_job(job)
job.valid = false
end

local function select_nonexisting_images(event, images)
local selection = {}

local job = dt.gui.create_job(_("select non existing images"), true, stop_job)
for key,image in ipairs(images) do
if(job.valid) then
job.percent = (key - 1)/#images
local filepath = image.path..PS..image.filename
local file_exists = df.test_file(filepath, "e")
dt.print_log(filepath.." exists? => "..tostring(file_exists))
if (not file_exists) then
table.insert(selection, image)
end
else
break
end
end
stop_job(job)

return selection
end

local function destroy()
dt.gui.libs.select.destroy_selection(MODULE)
end

dt.gui.libs.select.register_selection(
MODULE,
_("select non existing"),
select_nonexisting_images,
_("select all non-existing images in the current images"))

local script_data = {}
script_data.destroy = destroy
return script_data
12 changes: 12 additions & 0 deletions locale/de_DE/LC_MESSAGES/select_non_existing.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"

msgid "select non existing images"
msgstr "nicht vorhandene Bilder auswählen"

msgid "select non existing"
msgstr "nicht vorhandene auswählen"

msgid "select all non-existing images in the current images"
msgstr "alle nicht vorhandenen Bilder in den aktuellen Bildern auswählen"

0 comments on commit dc50d40

Please sign in to comment.