ExifTool Forum

ExifTool => Archives => Topic started by: Archive on May 12, 2010, 08:54:15 AM

Title: Append value to existing tag
Post by: Archive on May 12, 2010, 08:54:15 AM
[Originally posted by loloeroket on 2008-02-18 10:35:54-08]

Hello,

I am trying to use template files to adjust iptc tags:

exiftool -@ template.args file.jpg

where template.args looks like this:

# template.args

-IPTC:CopyrightNotice=Text
-IPTC:By-line=Text
-IPTC:Credit=Text
-IPTC:Caption-Abstract=$caption-abstract Text
# end

I end up with Caption field looking like that:
$caption-abstract Text.

Is there a way to do this or do I have to use command line?

Thanks,
Laurent
Title: Re: Append value to existing tag
Post by: Archive on May 12, 2010, 08:54:15 AM
[Originally posted by loloeroket on 2008-02-18 10:51:05-08]

I realized that my first post is not readable. I am sorry and repost it:

I am trying to use template files to adjust iptc tags:
Code:
exiftool -@ template.args file.jpg
where template.args looks like this:

Code:
# template.args
Code:
-IPTC:CopyrightNotice=Text
Code:
-IPTC:By-line=Text
Code:
-IPTC:Credit=Text
Code:
-IPTC:Caption-Abstract=$caption-abstract Text
Code:
# end
I end up with Caption field looking like that: $caption-abstract Text. Is there a way to do this or do I have to use command line?
 Thanks, Laurent
Title: Re: Append value to existing tag
Post by: Archive on May 12, 2010, 08:54:15 AM
[Originally posted by exiftool on 2008-02-18 13:50:35-08]

Hi Laurent,

This will work if you use the proper argument syntax.

For the caption-abstract, you don't want to assign a new
value (with "=").  Instead, you want to "redirect"
the value from another tag (with "&lt").  Of course,
in this case the tag is itself, but the same syntax applies:

Code:
-IPTC:Caption-Abstract<$caption-abstract Text

- Phil
Title: Re: Append value to existing tag
Post by: Archive on May 12, 2010, 08:54:15 AM
[Originally posted by loloeroket on 2008-02-19 09:35:37-08]

Hi Phil,

This is wonderful!
Is there by chance the possibility to replace some text by chance? I know I am pushing my luck.

Also if I want to compile several fields in one, I do like this?

Code:
-IPTC:Caption-Abstract<$caption-abstract Text $CreatedDate $City, $Country

I saw in the manual how to format the date.

And a last one for the road. Is there a way to make a carriage return?
 

Thanks,

Laurent
Title: Re: Append value to existing tag
Post by: Archive on May 12, 2010, 08:54:15 AM
[Originally posted by exiftool on 2008-02-19 13:41:55-08]

Hi Larent,

You can reformat the text any way you want by creating a user-defined
Composite tag to do what you want.  Search the forum and you will
see some examples of this.

$/ may be used for a newline.  You should read the -p
description in the application documentation because I'm sure you'll
have more questions that this may answer.

- Phil
Title: Re: Append value to existing tag
Post by: Archive on May 12, 2010, 08:54:15 AM
[Originally posted by loloeroket on 2008-02-20 06:45:00-08]

Thanks for the reply,

It sounds interesting this user-defined composite tag. I believe it is perl.. I need to dig into it.

Laurent
Title: Re: Append value to existing tag
Post by: Archive on May 12, 2010, 08:54:15 AM
[Originally posted by loloeroket on 2008-02-22 14:51:09-08]

I am coming back with my stupid questions.
I tried the '$/' in the .args but it prints ...'$/'. Also when the field  IPTC:caption-abstract doesn't exist in the file there is an error Warning: [minor] Tag 'caption-abstract' not defined - -, I read the manual (If a tag does not exist, the output value is set to '-' if the -f option is used.) but I tried to put -f but without success and my file is corrupted (4K).

I tried the -p option but it doesn't seem to work either in case of .args file. Or simply I don't get the syntax.

Laurent
Title: Re: Append value to existing tag
Post by: Archive on May 12, 2010, 08:54:15 AM
[Originally posted by exiftool on 2008-02-22 15:24:29-08]

Code:
> cat t.args
-IPTC:Caption-Abstract<$caption-abstract Text $CreatedDate $City, $Country $/ new line

> exiftool a.jpg -iptc:all

> exiftool a.jpg -@ t.args
Warning: [minor] Tag 'caption-abstract' not defined - a.jpg
    0 image files updated
    1 image files unchanged

> exiftool a.jpg -@ t.args -f
    1 image files updated

> exiftool a.jpg -iptc:all
Caption-Abstract                : - Text - -, - . new line
Application Record Version      : 4

> exiftool a.jpg -caption-abstract -b
- Text - -, -
 new line
Title: Re: Append value to existing tag
Post by: Archive on May 12, 2010, 08:54:16 AM
[Originally posted by loloeroket on 2008-02-22 18:32:38-08]

Then it must come from my piping then.

Code:
//Image is first processed in ImageMagick then Piped to exiftool
>convert $file_in -quality 85% -auto-orient - | exiftool -@ template.args -f ->$file_out
Title: Re: Append value to existing tag
Post by: Archive on May 12, 2010, 08:54:16 AM
[Originally posted by exiftool on 2008-02-22 19:10:15-08]

Yes.  That is the problem.  Currently tags can not be copied
in a pipeline.  This is because the copy is effectively a read
followed by a read/write, but a pipe can only be read once.

This is easier to understand when you realize there is an implicit
-tagsFromFile option whenever you copy tags.  So
your command is effectively:

Code:
... | exiftool -tagsfromfile - ... - > ...

- Phil
Title: Re: Append value to existing tag
Post by: Archive on May 12, 2010, 08:54:16 AM
[Originally posted by exiftool on 2008-02-22 19:23:17-08]

But of course, I should have realized that you don't need to
copy the tags in a pipeline anyway, since you should be able to
read the tags from the original file.  What about this?:

Code:
convert $file_in -quality 85% -auto-orient - | exiftool -tagsfromfile $file_in -@ template.args -f ->$file_out

- Phil
Title: Re: Append value to existing tag
Post by: Archive on May 12, 2010, 08:54:16 AM
[Originally posted by loloeroket on 2008-02-22 21:39:23-08]

I am getting the following error:

Code:
Error: File not found - +-
convert: Output file write error --- out of disk space? `-'.

Laurent
Title: Re: Append value to existing tag
Post by: Archive on May 12, 2010, 08:54:16 AM
[Originally posted by loloeroket on 2008-02-22 21:47:53-08]

But this is working!!

Code:
convert $file_in -quality 85% -auto-orient - | exiftool  -tagsfromfile $file_in -@ template.args -f ->$file_out

What to say?? you rock!!

Thanks for this, it makes a killer sequence now. I will try to do the same with a directory now, Actually if the metadatas are the same I can simply take the same file as reference. I think I start to understand how the whole thing is working. And just for fun, I will try in the same pipe sequence to rename and ftp. It must be funny!

Laurent

PS: Now by previewing my message I realize the + sign was added by the forum. What a dummy I am ;-)