[KPhotoAlbum] Command line filtering

Joe josephj at main.nc.us
Sun Feb 17 05:36:47 GMT 2019


On 2/16/19 7:17 PM, Robert Krawitz wrote:
> For a project I might or might not do, I was thinking of writing a
> script to list the images in an index.xml file, with optional
> filtering on the command line or via a file.
>
> The filter "syntax" would actually be a perl expression.  This sounds
> inefficient, but it can be done via creating the loop as a string with
> the filter expression embedded, and then eval'ing the entire loop.
> One-off tags like filename, start/end date, height, width etc. would
> be expressed as simple variables; an invocation might look like
>
> kpa-filter index.xml '($height * $width > 20000000) && (has_keyword("foo") || matches_person("krawitz") || matches_category("Places", "USA"))'
>
> or put the expression in a file and use it via -f.  The output would
> be a list of filenames.
>
> Do people think this would be interesting?  I should warn everyone
> that the next month will be very busy for me (I'm hoping it will be,
> at any rate) depending upon how deep we go in the NCAA Division III
> basketball postseason.
TL;DR: It's a great idea and creates many possibilities.

If I ever get around to actually tagging the rest of my photos, this
would be great to have. (I'm hopelessly far behind.)

Now, I can find almost anything (if it's tagged) using the KPA GUI, but
it would be cool to be able to write a bash script to do so without
having to open KPA.

If I wanted to reorganize my pictures (or, better yet, symlinks to them)
into folders based on tags, etc., that would take a long time to do in
the KPA GUI, but with your utility and a bash script it could be done in
moments - and updated any time with almost no additional effort.

The idea of being able to create virtual folders of pictures (using
symlinks) seems like it would have applications because it would
effectively allow other arbitrary applications to use the information
from the KPA indexes without even knowing that KPA exists. This would
also work by directly using the file lists your program would produce
(for programs that process file lists.)

You could do things like tag some photos with a particular tag and then
have an automated script come along later and find them and put them
through an automated work flow. Lots of possibilities!

I assume when you say "file names", you mean file paths - because the
name alone wouldn't tell you where they are - and there could be files
with duplicate names in different directories.

Also, the syntax of your example above would need a bit of tweaking. It
has to be able to reference whatever categories and tags the user has
defined in KPA. E.g. I have a top level category of Animals that I would
need to be able select values from.

I don't actually need to do any of this now, but I bet someone else does.

I guess I'd have to learn some perl to use this. I know bash and GNU
BREs and EREs.

Joe



More information about the Kphotoalbum mailing list