How to format mutiple tags Keywords extraction?

Started by Lagrandeimage, May 11, 2019, 03:56:57 PM

Previous topic - Next topic

Lagrandeimage

Hello all,

I have added to the Keywords field of every of my pics several tags through the Photoshop Elements program.

So for example, one file might have the Keywords Home, Baby, Food, Play.

I would like to extract all Keywords to datamine them, notably to count them.

Using exiftool -T Keywords a.jpg  > out.txt gives me the following :

Home, Baby, Food, Play

Using exiftool -T Keywords -csv a.jpg  out.csv gives me:

SourceFile,Keywords
a.jpg,"Home, Baby, Food, Play"

Can I format the output so that each of the tags in the Keywords field is listed on one line. For example, I would like to have the following output for a file:

Home
Baby
Food
Play

Is this possible?

Thanks in advance for your help!

Cheers,

Alan Clifford

exiftool -keywords  w300_1349_wb.jpg -sep "\n" -b

Barbados
scuba
Fork Reef
Hawsbill


Worked for me.  Run exiftool and search for -sep in the documentation as I am not sure of the implications of the -b flag.

Lagrandeimage

Hi Alan,

Just great, awesome!

Worked for me too!  :)

Thanks a lot!

Cheers,

StarGeek

Quote from: Alan Clifford on May 11, 2019, 05:23:23 PM
Worked for me.  Run exiftool and search for -sep in the documentation as I am not sure of the implications of the -b flag.

Actually, the -sep option isn't doing anything in this case.  It's the -b (binary) option.  If you remove the -b, you'll get
Barbados\nscuba\nFork Reef\nHawsbill

An additional problem with just -b will be that the results will bleed into each other.  So if there's more than one file, you'll get something like
Barbados
scuba
Fork Reef
HawsbillBarracuda
Coral Reef

where Barracuda is from the next file in line.

Try the -n (printConv) option
exiftool -p "${keywords;s/, /\n/g}" File1.jpg File2.jpg
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Phil Harvey

To avoid the bleeding problem, you could also do this:

exiftool -sep "\n" -sep "\n" -b FILE

(I had forgotten about this feature -- lucky we have such good documentation.)

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Lagrandeimage

Quote from: StarGeek on May 12, 2019, 03:45:32 AM
exiftool -p "${keywords;s/, /\n/g}" File1.jpg File2.jpg

Hello,

After trying the previous tip on several files, I had encoutered the bleeding problem abd was coming back to ask for an answer, but I find it already answered. This did the stuff and I have only one time per line even with several files.

Thanks a lot!

Lagrandeimage

Quote from: Phil Harvey on May 12, 2019, 07:58:32 AM
exiftool -sep "\n" -sep "\n" -b FILE

Yup also works!

Thanks a lot too!

Apart from the fact, it is a tad easier to write down than the other anti-bleed methode, any reason to prefer one or the other?

Cheers,

Phil Harvey

I can't see any reason that one technique is better than the other.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Lagrandeimage

Quote from: Phil Harvey on May 12, 2019, 08:34:53 AM
I can't see any reason that one technique is better than the other.

- Phil

Ok great thanks again for all the quick answers!

Cheers,