Has anyone wrote a script that writes any info to sidecar?

Remco Viëtor remco.vietor at wanadoo.fr
Tue May 16 06:52:16 BST 2017


On mardi 16 mai 2017 03:55:25 CEST HaJo Schatz wrote:
> On Tue, May 16, 2017 at 6:14 AM, <aegoreev at gmail.com> wrote:
> > Hello,
> > 
> > I am thinking of writing a script that would read GPS coordinates from a
> > video
> > file using mediainfo and paste them to xmp sidecar for digiKam to be able
> > to
> > read.
> > I am looking for a starting point. Does anyone have a script that writes
> > something in a text file?
> > 
> > I will probably be using MediaInfo to read the coordinates.
> > 
> > mediainfo FILE | grep "©xyz" | head -n 1
> > 
> > Thank you in advance for any ideas.
> 
> The good old awk, maybe?
And the shell echo works fine as well for writing to a text file.  I'm sure 
scripting languages like Perl Python also can write to text files :P. It all 
depends on what language will beused for the script.

But the main problem is not writing to the text file. You'll have to format the 
data correctly as well: XML is rather touchy wrt. syntax errors, those result 
in either a rejection of the complete file (as the readar bails out w/o giving 
any data to caller) or at best a missing tag (and having all your videos on 
the equator or the Greenwich meridian is perhaps not what you want). 

A quick look at one of my digikam xmp files shows 11 lines with GPS info, all 
as attributes to a <rdf:Description ...> tag. Which means that you can't just 
tack an extra element at the end of an existing xmp file.

I suppose you did see the --Inform and --Output options for mediainfo? Those 
might get you some of the required formatting. Transforming one form of XML in 
another might be easier than go through text (see XSLT).
disclaimer: I never used mediainfo.

Remco



More information about the Digikam-users mailing list