ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: 3design on November 10, 2012, 06:59:12 PM

Title: Possible to insert year into text string in field?
Post by: 3design on November 10, 2012, 06:59:12 PM
I'm working on creating a csv to batch-tag a collection of TIF files. One of the fields which I don't yet know how to handle is the copyright 'Rights' string. What I would like to do is something like what Photo Mechanic offers, namely a variable for the 4-digit year inserted into a text string, so, something like this:

SourceFile,Rights
"filename.tif","©{4-digit-year} Photographer Firstname, Lastname. All Rights Reserved."

Is there a way to do this with exiftool? I'm trying to avoid having to jump back and forth between multiple apps to complete all the tagging, and having the 4-digit modified date auto-inserted would save hours of manual editing.
Title: Re: Possible to insert year into text string in field?
Post by: Phil Harvey on November 11, 2012, 07:41:32 AM
This is the command:

exiftool -d %Y "-copyright<©$now Photographer Firstname, Lastname. All Rights Reserved." FILE

(use double quotes as above in Windows, or single quotes in Mac/Linux.)

You may have fun getting the special copyright symbol into the command line.  Special characters can be a challenge in Windows.  If you have trouble, use &copy; instead an add a -E option to the command.

See the Extra Tags documentation (https://exiftool.org/TagNames/Extra.html) if you are wondering about the Now tag.  Use any other date/time tag instead of "now" if you want the year to come from a date/time in the file.

- Phil
Title: Re: Possible to insert year into text string in field?
Post by: 3design on November 11, 2012, 10:17:44 AM
Hi Phil,

Thanks for the reply, the info is very helpful. I checked out the Now tag in the link. A couple further questions, for clarity..

The Now tag takes the full current date, but what I need to insert is the year, and only the year, from the Modified Date from the filesystem, which will be the date the file was created. It's weird in Windows, but the Created Date is not the real original date. So the Now date would be the current year, 2012, but for files from 2008, for example, that won't work...

Also, re your comment about the copyright symbol on the command line... I'm talking about writing all of this data from a pre-filled CSV file.. Please correct me if I'm wrong but I'm under the presumption that I can prefill a dozen IPTC fields in a CSV file for 100 images, and then apply all 1200 tags in one shot, right?

And, if so, is there a way to grab the 4-digit year (and not the rest of the date) from each image's filesystem Modify Date and write it into the "Rights" field? That way an image created in 2008 will automatically get 2008 inserted in the Rights field, and a 2010 will get 2010, etc... Again, this would be pre-filled in the "Rights" column in the CSV file, and not executed from command line, so the CSV would look something like what I imagined in my first post:

SourceFile,Rights
"filename.tif","©{4-digit-year} Photographer Firstname, Lastname. All Rights Reserved."

In other words, I guess the core of my question is, can a variable similar to $now (but one which shows the *filesystem Modify Date 4-digit year only* be pre-filled in the CSV cell, or will it only work from command line?
Title: Re: Possible to insert year into text string in field?
Post by: Phil Harvey on November 11, 2012, 03:31:16 PM
Quote from: 3design on November 11, 2012, 10:17:44 AM
The Now tag takes the full current date, but what I need to insert is the year, and only the year, from the Modified Date from the filesystem, which will be the date the file was created. It's weird in Windows, but the Created Date is not the real original date. So the Now date would be the current year, 2012, but for files from 2008, for example, that won't work...

Right.  Then use FileModifyDate instead of Now in the command.

QuoteAlso, re your comment about the copyright symbol on the command line... I'm talking about writing all of this data from a pre-filled CSV file.. Please correct me if I'm wrong but I'm under the presumption that I can prefill a dozen IPTC fields in a CSV file for 100 images, and then apply all 1200 tags in one shot, right?

Right.  But for this tag you want to copy information from existing tags, so using a CSV isn't the way to go for the Rights tag.  You can use the CSV for everything else, and set the Rights with -d %Y "-rights<©$filemodifydate Photographer Firstname, Lastname. All Rights Reserved.".

QuoteI guess the core of my question is, can a variable similar to $now (but one which shows the *filesystem Modify Date 4-digit year only* be pre-filled in the CSV cell, or will it only work from command line?

Only from the command line.

- Phil