Am Dienstag, 6. Oktober 2015, 17:29:54 schrieb Tobias Ellinghaus:
> Am Dienstag, 6. Oktober 2015, 07:16:04 schrieb darkta...@911networks.com:
> > On Tue, 06 Oct 2015 11:03:20 +0200
> > 
> > Tobias Ellinghaus <h...@gmx.de> wrote:
> > >> It would be handy to be able to "export" a list of files which
> > >> match the current search/collect/filter/sort criteria, so that one
> > >> can easily trigger an external action on these images.
> > >
> > >Using Lua for that should be easy.
> > 
> > Easy for people with experience in Lua. Do you have some sample for
> > newbie like me?
> 
> No sample, sorry. The general idea would be to register a new export storage
> and just output the list of images while not actually exporting anything. I
> will try to write some sample code later.

Ok, here is the first version (it will ONLY work in builds from git master). 
It adds a new button to the selected images-module on lighttable and when 
clicked it writes a list of all selected images to /tmp/selected_images.

--------------

local dt = require "darktable"

dt.gui.libs.image.register_action(
  "export list",
  function(event, images)
    local f = io.open("/tmp/selected_images", "w")
    if not f then
      dt.print("error writing to `/tmp/selected_images'")
    else
      for _, i in ipairs(images) do
        f:write(i.path.."/"..i.filename.."\n")
      end
      f:close()
      dt.print("list of selected images written to `/tmp/selected_images'")
    end
  end,
  "export a list of selected images to /tmp/selected_images.txt"
)

--------------

There are two alternative versions I will try:

- a backwards compatible keyboard shortcut that just exports such a list with 
all selected images (i.e., replace the button with a shortcut) and

- a pretty version that adds a completely new module on lighttable with a file 
picker that lets you decide where to export the list to. Unfortunately Lua can 
only add a button to the selected images-module and not arbitrary widgets.

If anyone wants to give it a try, you can get all selected images with this 
snippet:

for _, i in ipairs(dt.gui.selection()) do
  print(i.path..'/'..i.filename)
end

Tobias

Attachment: signature.asc
Description: This is a digitally signed message part.

------------------------------------------------------------------------------
_______________________________________________
Darktable-users mailing list
Darktable-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/darktable-users

Reply via email to