Change/Replace <return> character by <comma> in batch

Started by RNu, November 08, 2011, 12:37:41 PM

Previous topic - Next topic

RNu

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

Phil Harvey

Hi Ricky,

Yes.  Substitutions like this may be done with user-defined tags.  See this post 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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).