ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: RNu on November 08, 2011, 12:37:41 PM

Title: Change/Replace <return> character by <comma> in batch
Post by: RNu on November 08, 2011, 12:37:41 PM
Hi all,

I have looked around on the forum to see whether some similir question was posed before but didn't find it.

A friend of mine is a professional photographer and has recently loaded his last 2 years of footage into Picasa.
He's using a Mac. It turns out that the <return> character he used in his "description" field, is neglected in Picasa.

So what I would like to do is create a batch program that goes over all his jpg photos, open the metadata, scan for the <return> character, replace it by a , and save the file.

Is something like that possible with the ExifTool?

Kind regards,
Ricky
Title: Re: Change/Replace <return> character by <comma> in batch
Post by: Phil Harvey on November 08, 2011, 01:08:22 PM
Hi Ricky,

Yes.  Substitutions like this may be done with user-defined tags.  See this post (https://exiftool.org/forum/index.php/topic,2961.msg13270.html#msg13270) for an example.  You might want a conversion something like this:

       ValueConv => ''$val =~ tr/\n/,/ ? $val : undef',

This will return an undefined value if nothing was replaced (which is what you want, because then the value will be copied only when it contains a newline.  There is one variable, however.  What type of newline is it?  Maybe it is safer to do this:

       ValueConv => ''$val =~s/(\x0d\x0a|0x0d|\x0a)/,/g ? $val : undef',

To replace any of the various combinations.

The command line will look something like this:

exiftool "-description<mydescription" DIR

- Phil