keywords by folder rather than individual file/image

Started by DaveBryant, June 03, 2021, 10:08:43 PM

Previous topic - Next topic

DaveBryant

Definite Newbie here

I have camera trapping data, lots of images for each camera, each image tagged with species names. This was done within DigiKam.

Each camera has it's own folder with images contained.

I have managed to get exiftool to output the tags for each image (-filename -keywords -csv -ext JPG) , but what I would like to do is get a tag list for each camera/folder (rather than individual images). This would essentially give me a list of the species captured for each camera.

Any suggestions appreciated.

Luuk2005

#1
Sorry, but Im not really understanding the english.
If wanting to include folder-names inside the .csv, you can add some tags like -directory or -filepath to the command.
If only wanting to conduct certain folders, the command can be like... exiftool -options Folder1 Folder2 ...

Edit: If to experiment with something like... exiftool -r -options -directory . to conduct all sub-folders...
Then its good to add something like -fileorder directory to make the directory-order better inside of the csv.
Windows8.1-64bit,  exiftool-v12.92(standalone),  sed-v4.0.7

StarGeek

Since exiftool only parses one file at a time, there really isn't a mechanic to compile a list of keywords between files.  This is usually something left to a script or if you're on a linux OS, using sed.

If you have Perl installed, I have a short Perl script that I pipe exiftool's output into and will return a consolidated list of keywords that I can post.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Luuk2005

Many apologies, I should read the title better! Because thinking you wanted a .csv with having all of the $keywords.
Im not expert to know how to conduct this like StarGeek says with the perl, and also not having the perl installed anyway.
If you have the sed.exe with Windows, I can give example, but its a very long command like...
exiftool -q -r -fileorder directory -if $keywords -sep "||" -p "#[SECT]==$DIRECTORY==" -p "$keywords" -p "#[ENDS]==$Directory==" "DIR" |sed -r -n "/^==/,/==$/{H;g;/\n==.*\n.*==$/{s/^\n//;s/(\n|[|]{2})/\n\n/g;:a;s/(\n[^\n]{1,}\n)(.*)\1/\1\2/;ta;s/\n\n/, /g;s/(==.*==), (.*), \1$/\1\n\2\n/p;s/.*//;x;}}" 

Inside the windows cmd.exe, it presents the output like...
==FolderName1==
keyword1, keyword2, keyword3 (destroying duplicate keywords, and presenting them all on one-line)

==FolderName2==
keyword1, keyword2, keyword3 (destroying duplicate keywords, and presenting them all on one-line)


I can help to modify if using the windows cmd.exe, but sorry Im no ideas how to modify this, for using inside of other shells.
The sed command does seem over complicated , so Im thinking the perl probably presents an easier way to make modifications.
Also, even if having sed.exe with windows, Im still very interested to discover the perl method to conduct something similiar.
Windows8.1-64bit,  exiftool-v12.92(standalone),  sed-v4.0.7

StarGeek

Here's my Perl script.  This is actually trimmed down to just Subject and Keywords.  My actual use case includes many other tags, including a lot of user defined tags.

Tags.pl
use strict;
my %hash;
my @arr;
while (<>) {
s/((?!(?:(?:Subject|Keywords)) +: ).)*//i; # Strip away any line that is not Subject/Keywords
s/^(?:(?:Subject|Keywords)) +: //i; # Strip away leading text
s/^\s+|\s+$//g; # Trim leading/trailing spaces
  push (@arr, split /##/);
}

print "\n---------------\n";
print join("\n",sort(uniq(@arr)))."\n";

exit;
sub uniq {
    my %seen;
    grep !$seen{$_}++, @_;
}


Example command and output


C:\WINDOWS\system32>exiftool -Subject -Keywords Y:/Pictures/Camera_Pictures/!Starting_Over/SDWAP/2013-07-30/ -sep ## -if "$Keywords or $Subject" -s | Tags.pl

---------------
African Elephant
African Spoonbill
Barbara D.
Black Crowned Crane
California Condor
Cheetah
Cormorant
Desert Bighorn Sheep
Duck
Gazelle
Giraffe
Gnu
Gorilla
Hot Air Balloon
Identification Photo
Jeep
Karen C.
Lemur
Lorikeet
Natalie H.
Nicobar Pigeon
Pelican
Rhinoceros
San Diego Safari Park
Somalian Wild Donkey
Southern Bald Ibis
Spencer H.
Statue
Storm's Stork
Ungulates
Unknown Bird
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Luuk2005

Many thanks for the perl script.. I dont know if I will ever understand it, but at least now its saved inside my bookmarks.
I think that once understanding the code, this perl is much better for making modifications, than using the sed-scripts.
Also, its making the keywords to be alphabetical and case-insensitive, so this can be another improvement.

Im not think to use the i-modifier or piping through sort, so Im certain it would present both 'KeyWord1' and 'KEYword1', thinking them to be different.
And also certainly never alphabetized, so now Im really wishing I did have the perl installed, just to experiment with this. Thanks again!
Windows8.1-64bit,  exiftool-v12.92(standalone),  sed-v4.0.7