ExifTool Forum

ExifTool => Newbies => Topic started by: Joao on October 08, 2018, 12:41:22 PM

Title: Help: Removing line breaks unconditionaly in TAGS and returning new TAG name
Post by: Joao on October 08, 2018, 12:41:22 PM
https://exiftool.org/forum/index.php/topic,1962.msg8559.html#msg8559 (https://exiftool.org/forum/index.php/topic,1962.msg8559.html#msg8559)
But it does not work for me, unless there is a line break in the tag, otherwise it is not displayed in the output.
I was hoping to ignore all tags with line breaks and instead using all the new tags which I generated using the config file

Example:

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        'NEW Description' => {
            Require => 'Description',
            ValueConv => '$val =~ s/[\n\r]+/ /g ? $val : undef',
        },
        'NEW Subject' => {
            Require => 'Subject',
            ValueConv => '$val =~ s/[\n\r]+/ /g ? $val : undef',
        },
        'NEW Keywords' => {
            Require => 'Keywords',
            ValueConv => '$val =~ s/[\n\r]+/ /g ? $val : undef',
        },
        'NEW Caption-Abstract' => {
            Require => 'Caption-Abstract',
            ValueConv => '$val =~ s/[\n\r]+/ /g ? $val : undef',
        },
        'NEW ImageDescription' => {
            Require => 'ImageDescription',
            ValueConv => '$val =~ s/[\n\r]+/ /g ? $val : undef',
       },
    },
);

My question is, how can I modify this config file, so that regardless a line break or not in a tag, the NEW tag is generated in the output?


Thanks for your help in advance!

Joao


[/list]
Title: Re: Help: Removing line breaks unconditionaly in TAGS and returning new TAG name
Post by: StarGeek on October 08, 2018, 02:53:13 PM
Good for you for searching through the archives.  But that post is outdated and exiftool can now do global arbitrary string processing with the -api Filter option.

To replace 1 or more CR/LF with a single space (as you show in your user defined tags), you can do this
exiftool -a -csv -G1 -s -r --Keywords  -api "Filter=s/[\n\r]+/ /g" s:\ >"output.txt"
Title: Re: Help: Removing line breaks unconditionaly in TAGS and returning new TAG name
Post by: Joao on October 08, 2018, 06:53:26 PM
This is great, it solves my issue.

Thanks StarGeek ! :-)