ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: Zenta on May 12, 2011, 03:43:03 AM

Title: Create unique id in custom IPTC tag if not exist.
Post by: Zenta on May 12, 2011, 03:43:03 AM
Hi

I would like to add a timestamp or uniqueid to a files metadata IF that tag dont already exists.

I dont want to use IPTCDigest cause the MD5 hash is changed when metadata is changed. I would like to be able to track this file even if it is changed in many ways.

Is this possible with Exiftool?
Title: Re: Create unique id in custom IPTC tag if not exist.
Post by: Phil Harvey on May 12, 2011, 07:12:52 AM
Yes.

- Phil
Title: Re: Create unique id in custom IPTC tag if not exist.
Post by: Zenta on May 12, 2011, 07:58:19 AM
Great, im using the executeable exiftool.exe to extract metadata from a image to a string which i then write to an xml file.

Command  -X -fast c:\myImage.jpg

Soo my question is, can i run a command to add the timestamp to metadata before extracting the data to the string. Or do i need to seperate these two processes?
Is there any example code i can check to get started?
Title: Re: Create unique id in custom IPTC tag if not exist.
Post by: Phil Harvey on May 12, 2011, 09:34:10 AM
There are lots of simple examples in the ExifTool application documentation (https://exiftool.org/exiftool_pod.html#reading_examples).

You can execute multiple commands in the same command line with -execute:

exiftool -createdate="2011:05:12 09:35:13" a.jpg -execute -X -fast a.jpg

or

exiftool -createdate="2011:05:12 09:35:13" -execute -X -fast -common_args a.jpg

- Phil
Title: Re: Create unique id in custom IPTC tag if not exist.
Post by: Zenta on May 13, 2011, 04:02:07 AM
Thank you Phil, i got two commands working with your example.

Now, i would like to insert a unique ID (MD5 hash or whatever, i create this in my .net application). Then i would like to insert this ID into a suitable metadata field. The trick is, i do not want to update that field if it already has a value exists. Reason i want to do this is cause i would like to be able to track one image even if it changes in any way.

1. What is a suitable field to set a unique id that is not supposed to be updated again?
2. How do i set the command to not update if value exists?

Thanks soo far, appreciate it.
Title: Re: Create unique id in custom IPTC tag if not exist.
Post by: Phil Harvey on May 13, 2011, 07:09:35 AM
exiftool -imageuniqueid=test -imageuniqueid-= FILE

- Phil
Title: Re: Create unique id in custom IPTC tag if not exist.
Post by: Zenta on May 17, 2011, 08:36:54 AM
Works like a charm, many thanks Phil.