ExifTool Forum

ExifTool => Newbies => Topic started by: jobione on November 23, 2020, 02:17:39 PM

Title: Parse and Extracting UserComment into tag
Post by: jobione on November 23, 2020, 02:17:39 PM
1st off that was the most intuitive registration process I've ever done. lol I'm obviously a script kiddie here, so i def need some guidance.

I'm trying to extract specific data from the -user comment string and create a tag for it. It's for a camera trap and to me, it seems like the most important data outside of the date.
It's all listed under the single -user commment tag:
User Comment: MR=C.1,AD=9/23/2020,LD=4,BT=15,RD=0,LH=0,LI=493,BL=9432,BP=99%,BS=Ext,BD=4,BI=2327,CF=Disabled,IR=100%MAX,WL=850nm,EX=Centered,ID=S.I. SOUTH,LO=003,MA=201E524A896E,SM=ADV,DD=1min,DI=1,DV=OFF,DL=OFF,ND=15sec,NI=1,NV=OFF,NL=OFF

Is it possible to extract the "," separated data into individual tags? I've tried exiftool -sep "," -UserComment T_00010.JPG, but i'm lacking the foundational knowledge.

Thanks in advance!
Title: Re: Parse and Extracting UserComment into tag
Post by: StarGeek on November 23, 2020, 03:16:50 PM
It's possible to extract parts of that string, but what is your end goal?  Are you copying to another tag?
Title: Re: Parse and Extracting UserComment into tag
Post by: jobione on November 23, 2020, 03:56:59 PM
For my end goal, I'd like to be able to fwd that metadata and the values into grafana for analitycs. Every time an image gets upload on the drive the metadata gets extracted.

It looks like in order to do that it'll have be an xmp tag, since i'd like to use custom tagging as shown in the snapshot below?? (eg. (TAG1_MR=##), (TAG2_AD=XX/XX/XXXX), (TAG3_LD=X) etc..)
Title: Re: Parse and Extracting UserComment into tag
Post by: StarGeek on November 23, 2020, 05:42:30 PM
So just split everything into a separate line for each NAME=VALUE pair?
exiftool -p "${UserComment;s/,/\n/g}" File.jpg

Example output:
C:\>exiftool -p "${UserComment;s/,/\n/g}" y:\!temp\Test4.jpg
MR=C.1
AD=9/23/2020
LD=4
BT=15
RD=0
LH=0
LI=493
BL=9432
BP=99%
BS=Ext
BD=4
BI=2327
CF=Disabled
IR=100%MAX
WL=850nm
EX=Centered
ID=S.I. SOUTH
LO=003
MA=201E524A896E
SM=ADV
DD=1min
DI=1
DV=OFF
DL=OFF
ND=15sec
NI=1
NV=OFF
NL=OFF


Though running it on multiple files would require some tweaking to be able to separate the outputs.