How to prevent empty Keyword and reduce repeated code?

Started by J4c06r1nw1s, January 03, 2022, 10:51:46 AM

Previous topic - Next topic

J4c06r1nw1s

How to prevent empty KeyWord?

And how can i reduce repeated code?
I've already shortened the code for the question on this forum a lot.


If there is no Make and Model then it creates empty keywords

-sep ', ' '-KeyWords<$Make, $Model, $Make $Model'



~/test$ exiftool -s image.jpg -KeyWords
======== ./image.jpg
Keywords                        : , ,
    1 directories scanned
    1 image files read


exiftool \
    -if 'not $XMPToolkit' \
    '-FileName</volume1/media/${FileModifyDate#;DateFmt("%Y/%m/%d")}/${FileModifyDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/${CreateDate#;DateFmt("%Y/%m/%d")}/${CreateDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/${DateTimeOriginal#;DateFmt("%Y/%m/%d")}/${DateTimeOriginal;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/$Make/$Model/${FileModifyDate#;DateFmt("%Y/%m/%d")}/${Make}_${Model}_${FileModifyDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/$Make/$Model/${CreateDate#;DateFmt("%Y/%m/%d")}/${Make}_${Model}_${CreateDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/$Make/$Model/${DateTimeOriginal#;DateFmt("%Y/%m/%d")}/${Make}_${Model}_${DateTimeOriginal;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    -overwrite_original \
    -sep ', ' '-KeyWords<$Make, $Model, $Make $Model' \
    -r '/volume1/footage/PHOTOS' \
-execute \
    -if '$XMPToolkit' \
    '-FileName</volume1/media/${FileModifyDate#;DateFmt("%Y/%m/%d")}/EDIT/${FileModifyDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/${CreateDate#;DateFmt("%Y/%m/%d")}/EDIT/${CreateDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/${DateTimeOriginal#;DateFmt("%Y/%m/%d")}/EDIT/${DateTimeOriginal;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/$Make/$Model/${FileModifyDate#;DateFmt("%Y/%m/%d")}/EDIT/${Make}_${Model}_${FileModifyDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/$Make/$Model/${CreateDate#;DateFmt("%Y/%m/%d")}/EDIT/${Make}_${Model}_${CreateDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/$Make/$Model/${DateTimeOriginal#;DateFmt("%Y/%m/%d")}/EDIT/${Make}_${Model}_${DateTimeOriginal;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    -overwrite_original \
    -sep ', ' '-KeyWords<$Make, $Model, $Make $Model' \
    -r '/volume1/footage/PHOTOS'


I could also do this.
But then I repeat some more code.


exiftool \
    -if '$Make and $Model and not $XMPToolkit' \
    '-FileName</volume1/media/$Make/$Model/${FileModifyDate#;DateFmt("%Y/%m/%d")}/${Make}_${Model}_${FileModifyDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/$Make/$Model/${CreateDate#;DateFmt("%Y/%m/%d")}/${Make}_${Model}_${CreateDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/$Make/$Model/${DateTimeOriginal#;DateFmt("%Y/%m/%d")}/${Make}_${Model}_${DateTimeOriginal;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    -overwrite_original \
    -sep ', ' '-KeyWords<$Make, $Model, $Make $Model' \
    -r '/volume1/footage/PHOTOS' \
-execute \
    -if 'not $Make and not $Model and not $XMPToolkit' \
    '-FileName</volume1/media/${FileModifyDate#;DateFmt("%Y/%m/%d")}/${FileModifyDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/${CreateDate#;DateFmt("%Y/%m/%d")}/${CreateDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/${DateTimeOriginal#;DateFmt("%Y/%m/%d")}/${DateTimeOriginal;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    -r '/volume1/footage/PHOTOS' \
-execute \
    -if '$Make and $Model and $XMPToolkit' \
    '-FileName</volume1/media/$Make/$Model/${FileModifyDate#;DateFmt("%Y/%m/%d")}/EDIT/${Make}_${Model}_${FileModifyDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/$Make/$Model/${CreateDate#;DateFmt("%Y/%m/%d")}/EDIT/${Make}_${Model}_${CreateDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/$Make/$Model/${DateTimeOriginal#;DateFmt("%Y/%m/%d")}/EDIT/${Make}_${Model}_${DateTimeOriginal;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    -overwrite_original \
    -sep ', ' '-KeyWords<$Make, $Model, $Make $Model' \
    -r '/volume1/footage/PHOTOS' \
-execute \
    -if 'not $Make and not $Model and $XMPToolkit' \
    '-FileName</volume1/media/${FileModifyDate#;DateFmt("%Y/%m/%d")}/EDIT/${FileModifyDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/${CreateDate#;DateFmt("%Y/%m/%d")}/EDIT/${CreateDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/${DateTimeOriginal#;DateFmt("%Y/%m/%d")}/EDIT/${DateTimeOriginal;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    -r '/volume1/footage/PHOTOS'


PH Edit: Used "code" blocks instead of "tt"
Using ExifTool v12.37 on Linux

StarGeek

By default, that command should fail with a "No writable tags set" warning if either one of those tags do not exist.  So I'm guessing that you have another option set that will override that, maybe the -m (-ignoreMinorErrors) option or the -f (-ForcePrint) option with the -api MissingTagValue option set.

Offhand I can't think of an easy way to do this on the command line in a single command that won't fail or set an empty keyword.  The only way I can think of would require use of the .ExifTool_config and either a short cut or user defined tag.  Phil may come up with some magic way, though.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

J4c06r1nw1s

I am using a config file.
MyMake MyModel and MyMakeAndModel has underscores in the names.
MyMake = DJI
MyModel = AIR_2S
MyMakeAndModel = DJI_AIR_2S
I replace the underscores with spaces.
Could something go wrong there?


-sep ', ' '-KeyWords<${MyMake;s|_| |g}, ${MyModel;s|_| |g}, ${MyMakeAndModel;s|_| |g}' \
Using ExifTool v12.37 on Linux

StarGeek

Quote from: J4c06r1nw1s on January 03, 2022, 11:50:00 AMI replace the underscores with spaces.
Could something go wrong there?

No, the problem is that you are using another option that forces writing of blank tags, as I said above.

If you disable that, you could make a shortcut tag like this
%Image::ExifTool::UserDefined::Shortcuts = (
MyMakeModel => ['Make','Model'],
);


This could be used to write both tags and not fail if one or the other didn't exist.  But that wouldn't take care of the combined keyword you want to write, so that would require a user defined tag, which would be along these lines
MyMakeModel => {
Desire => {
0 => 'Make',
1 => 'Model',
ValueConv => q{
my @RetArr= ();
push (@RetArr, $val[0]) if (defined $val[0]);
push (@RetArr, $val[1]) if (defined $val[1]);
push (@RetArr, "$val[0] $val[1]) if (defined $val[0] and defined $val[0]);
return @RetArr? \@RetArr:undef;
},
},

Then you would use this to write all three keywords at once. There must not be a dollar sign or else you have to include the -sep option.
'-Keywords<MyMakeModel'


"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

J4c06r1nw1s

#4
Maybe I should show more clearly what I'm doing.

I did it like this. Is this good too?


%Image::ExifTool::UserDefined = (
'Image::ExifTool::Composite' => {
#-------------------------------------------------------------------------------
        MyMake => {
            Desire => {
                0 => 'Make',
                1 => 'Model',
                2 => 'FileName',
                3 => 'FirmwareVersion',
                4 => 'ImageSize',
                5 => 'ProjectionType',
                6 => 'Encoder',
                7 => 'FileType',
                8 => 'HandlerDescription'
            },
            ValueConv => q{
                my $Make = $val[0];
                my $Model = $val[1];
                my $FileName = $val[2];
                my $FirmwareVersion = $val[3];
                my $ImageSize = $val[4];
                my $ProjectionType = $val[5];
                my $Encoder = $val[6];
                my $FileType = $val[7];
                my $HandlerDescription = $val[8];

#-------------- DJI ------------------------------------------------------------
                $Make = 'DJI' if $Model eq 'FC300XW';           # <-- PHANTOM 3 4K
                $Make = 'DJI' if $Model eq 'FC300X';            # <-- PHANTOM 3 PROFESSIONAL
                $Make = 'DJI' if $Model =~ m/^FC220/;           # <-- MAVIC PRO
                $Make = 'DJI' if $Model eq 'FC7203';            # <-- MAVIC MINI
                $Make = 'DJI' if $Model eq 'FC7303';            # <-- MINI 2
                $Make = 'DJI' if $Encoder eq 'Lavf56.15.102';   # <-- AIR 2S
                $Make = 'DJI' if $Model eq 'Osmo Pocket';       # <-- OSMO POCKET
                $Make = 'DJI' if $Model eq 'Osmo Mobile 2';     # <-- OSMO MOBILE 2
                $Make = 'DJI RYZE' if $Model eq 'RZ001';        # <-- TELLO

#-------------- GOPRO ----------------------------------------------------------
                $Make = 'GOPRO' if $FirmwareVersion eq 'HD3.03.03.00'; # <-- HERO3
                $Make = 'GOPRO' if $Model eq 'HERO6 Black';
                $Make = 'GOPRO' if $Model eq 'HERO7 Black';
                $Make = 'GOPRO' if $Model eq 'GoPro Max';
                $Make = 'GOPRO' if $ImageSize == '3840x1920' && $ProjectionType eq 'equirectangular'; # <-- MAX

#-------------- HP -------------------------------------------------------------
                $Make = 'HP' if $Make =~ /Hewlett-Packard/i;

#-------------- INSTA360 ------------------------------------------------------
                $Make = 'INSTA360' if $FileType =~ m/INSV/;
                $Make = 'INSTA360' if $Encoder =~ m/Lavf58.13.101/;

#-------------- KODAK ---------------------------------------------------------
                $Make = 'KODAK' if $Make =~ m/KODAK/i;

#-------------- MEDION --------------------------------------------------------
                $Make = 'MEDION' if $Make =~ m/Medion/i;

#-------------- MINOLTA -------------------------------------------------------
                $Make = 'MINOLTA' if $Make =~ m/Minolta/i;

#-------------- NIKON ---------------------------------------------------------
                $Make = 'NIKON' if $Make =~ m/NIKON/i;

#-------------- OLYMPUS -------------------------------------------------------
                $Make = 'OLYMPUS' if $Make =~ m/OLYMPUS/i;

#-------------- PENTAX --------------------------------------------------------
                $Make = 'PENTAX' if $Make =~ m/PENTAX/i;

#-------------- SAMSUNG -------------------------------------------------------
                $Make = 'SAMSUNG' if $Make =~ m/SAMSUNG/i;
                $Make = 'SAMSUNG' if $FileName =~ m/360_\d{4}_stitched_straightened_injected/i;

#-------------- XIAOMI --------------------------------------------------------
                $Make = 'XIAOMI' if $Model eq 'POCOPHONE F1';
                $Make = 'XIAOMI' if $FileName =~ m/VID_\d{8}_\d{6}/;
                $Make = 'XIAOMI' if $Model eq 'POCOPHONE F1(Shot on GCam from Urnyx05)';

#-------------- XIAOYI --------------------------------------------------------
                $Make = 'XIAOYI' if $HandlerDescription eq 'XiaoYi AAC';

                $Make =~ s/\s/_/g;

                return uc $Make;
            },
        },
#-------------------------------------------------------------------------------
        MyModel => {
            Desire => {
                0 => 'Make',
                1 => 'Model',
                2 => 'Encoder',
                3 => 'FileType',
                4 => 'CameraSerialNumber',
                5 => 'ContentCistributor',
                6 => 'HandlerDescription',
                7 => 'FileName',
                8 => 'FirmwareVersion',
                9 => 'ImageSize',
                10 => 'ProjectionType'
            },
            ValueConv => q{
                my $Make = $val[0];
                my $Model = $val[1];
                my $Encoder = $val[2];
                my $FileType = $val[3];
                my $CameraSerialNumber = $val[4];
                my $ContentCistributor = $val[5];
                my $HandlerDescription = $val[6];
                my $FileName = $val[7];
                my $FirmwareVersion = $val[8];
                my $ImageSize = $val[9];
                my $ProjectionType = $val[10];

#-------------- AUKEY ---------------------------------------------------------
                $Model =~ s/AUKEY //;

#-------------- CANON ---------------------------------------------------------
                $Model =~ s/Canon //i;

#-------------- DJI ------------------------------------------------------------
                $Model = 'PHANTOM 3 4K' if $Model eq 'FC300XW';
                $Model = 'PHANTOM 3 PROFESSIONAL' if $Model eq 'FC300X';
                $Model = 'MAVIC PRO' if $Model =~ m/^FC220/i;
                $Model = 'MAVIC MINI' if $Model eq 'FC7203';
                $Model = 'MINI 2' if $Model eq 'FC7303';
                $Model = 'AIR 2S' if $Encoder eq 'Lavf56.15.102';
                $Model = 'TELLO' if $Model eq 'RZ001';

#-------------- EPSON ----------------------------------------------------------
                $Model =~ s/Epson //i;

#-------------- GOPRO ----------------------------------------------------------
                $Model = 'HERO3' if $FirmwareVersion eq 'HD3.03.03.00';
                $Model = 'HERO3' if $Model eq 'GDH30';
                $Model = 'HERO7 BLACK C1' if $CameraSerialNumber eq 'C3281324648249';
                $Model = 'HERO7 BLACK C2' if $CameraSerialNumber eq 'C3281328673787';
                $Model = 'MAX' if $Model eq 'Max';
                $Model = 'Max' if $ImageSize == '3840x1920' && $ProjectionType eq 'equirectangular'; # <-- .MP4
                $Model = 'Max' if $CameraSerialNumber eq 'C3353424543326';                           # <-- .360

#-------------- HP -------------------------------------------------------------
                $Model =~ s/HP //i;

#-------------- INSTA360 ------------------------------------------------------
                $Model = 'GO' if $FileType eq 'INSV';
                $Model = 'GO' if $Encoder eq 'Lavf58.13.101';

#-------------- KODAX ---------------------------------------------------------
                $Model = 'DX7590' if $Model =~ m/DX7590/i;
                $Model = 'HR200' if $Model =~ m/HR200/i;

#-------------- NIKON ---------------------------------------------------------
                $Model =~ s/NIKON //;

#-------------- PENTAX --------------------------------------------------------
                $Model = 'OPTIO 50' if $Model =~ m/PENTAX Optio 50/i;

#-------------- SAMSUNG -------------------------------------------------------
                $Model = 'GALAXY S20 ULTRA' if $Model eq 'SM-G988B';
                $Model = 'GALAXY TAB S6' if $Model eq 'SM-T860IMX';
                $Model = 'GALAXY MINI' if $Model eq 'GT-S5570';
                $Model = 'GALAXY S6 EDGE' if $Model eq 'SM-G925F';
                $Model = 'GEAR 360 2016' if $Model eq 'SM-C200';
                $Model = 'GEAR 360 2017' if $Model eq 'SM-R210';
                $Model = 'GEAR 360' if $FileName =~ m/360_\d{4}_stitched_straightened_injected/i;
                $Model = 'DIGIMAX L55W' if $Model =~ m/Digimax L55W/i;
                $Model = 'DIGIMAX S600' if $Model =~ m/Digimax S600/i;

#-------------- XIAOMI --------------------------------------------------------
                $Model = 'POCOPHONE F1' if $FileName =~ m/POCOPHONE F1/i;
                $Model = 'POCOPHONE F1' if $FileName eq 'Poco F1';
                $Model = 'POCOPHONE F1' if $FileName =~ m/VID_\d{8}_\d{6}/i;
                $Model = 'YI 2 4K' if $Model eq 'YDXJ 2';
                $Model = 'YI 2 4K' if $ContentCistributor eq 'YDXJ 2';
                $Model = 'YI 2 4K' if $HandlerDescription eq 'XiaoYi AAC';

                $Model =~ s/\s/_/g;

                return uc $Model;
            },
        },
#-------------------------------------------------------------------------------
        MyMakeAndModel => {
            Desire => {
                0 => 'MyMake',
                1 => 'MyModel'
            },
            ValueConv => q{
                my $MyMake = $val[0];
                my $MyModel = $val[1];

                return join '_', $MyMake, $MyModel;
            },
        },
#------------------------------------------------------------------------------
    },
);
1;  #end


Method 1

exiftool \
-config config \
    -if 'not $XMPToolkit' \
    '-FileName</volume1/media/${FileModifyDate#;DateFmt("%Y/%m/%d")}/${FileModifyDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/${CreateDate#;DateFmt("%Y/%m/%d")}/${CreateDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/${DateTimeOriginal#;DateFmt("%Y/%m/%d")}/${DateTimeOriginal;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/$MyMake/$MyModel/${FileModifyDate#;DateFmt("%Y/%m/%d")}/${MyMakeAndModel}_${FileModifyDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/$MyMake/$MyModel/${CreateDate#;DateFmt("%Y/%m/%d")}/${MyMakeAndModel}_${CreateDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/$MyMake/$MyModel/${DateTimeOriginal#;DateFmt("%Y/%m/%d")}/${MyMakeAndModel}_${DateTimeOriginal;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    -overwrite_original \
    -sep ', ' '-KeyWords<${MyMake;s|_| |g}, ${MyModel;s|_| |g}, ${MyMakeAndModel;s|_| |g}' \
    -r '/volume1/footage/PHOTOS' \
    -@ args \
-execute \
    -if '$XMPToolkit' \
    '-FileName</volume1/media/${FileModifyDate#;DateFmt("%Y/%m/%d")}/EDIT/${FileModifyDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/${CreateDate#;DateFmt("%Y/%m/%d")}/EDIT/${CreateDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/${DateTimeOriginal#;DateFmt("%Y/%m/%d")}/EDIT/${DateTimeOriginal;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/$MyMake/$MyModel/${FileModifyDate#;DateFmt("%Y/%m/%d")}/EDIT/${MyMakeAndModel}_${FileModifyDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/$MyMake/$MyModel/${CreateDate#;DateFmt("%Y/%m/%d")}/EDIT/${MyMakeAndModel}_${CreateDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/$MyMake/$MyModel/${DateTimeOriginal#;DateFmt("%Y/%m/%d")}/EDIT/${MyMakeAndModel}_${DateTimeOriginal;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    -overwrite_original \
    -sep ', ' '-KeyWords<${MyMake;s|_| |g}, ${MyModel;s|_| |g}, ${MyMakeAndModel;s|_| |g}' \
    -r '/volume1/footage/PHOTOS'
    -@ args \
    -common_args -ext jpg


Method 2

exiftool \
-config config \
    -if '$MakeAndModel and not $XMPToolkit' \
    '-FileName</volume1/media/$MyMake/$MyModel/${FileModifyDate#;DateFmt("%Y/%m/%d")}/${MyMakeAndModel}_${FileModifyDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/$MyMake/$MyModel/${CreateDate#;DateFmt("%Y/%m/%d")}/${MyMakeAndModel}_${CreateDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/$MyMake/$MyModel/${DateTimeOriginal#;DateFmt("%Y/%m/%d")}/${MyMakeAndModel}_${DateTimeOriginal;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    -overwrite_original \
    -sep ', ' '-KeyWords<${MyMake;s|_| |g}, ${MyModel;s|_| |g}, ${MyMakeAndModel;s|_| |g}' \
    -r '/volume1/footage/PHOTOS' \
-execute \
    -if 'not $MakeAndModel and not $XMPToolkit' \
    '-FileName</volume1/media/${FileModifyDate#;DateFmt("%Y/%m/%d")}/${FileModifyDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/${CreateDate#;DateFmt("%Y/%m/%d")}/${CreateDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/${DateTimeOriginal#;DateFmt("%Y/%m/%d")}/${DateTimeOriginal;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    -r '/volume1/footage/PHOTOS' \
    -@ args \
-execute \
    -if '$MakeAndModel and $XMPToolkit' \
    '-FileName</volume1/media/$MyMake/$MyModel/${FileModifyDate#;DateFmt("%Y/%m/%d")}/EDIT/${MyMakeAndModel}_${FileModifyDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/$MyMake/$MyModel/${CreateDate#;DateFmt("%Y/%m/%d")}/EDIT/${MyMakeAndModel}_${CreateDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/$MyMake/$MyModel/${DateTimeOriginal#;DateFmt("%Y/%m/%d")}/EDIT/${MyMakeAndModel}_${DateTimeOriginal;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    -overwrite_original \
    -sep ', ' '-KeyWords<${MyMake;s|_| |g}, ${MyModel;s|_| |g}, ${MyMakeAndModel;s|_| |g}' \
    -r '/volume1/footage/PHOTOS' \
    -@ args \
-execute \
    -if 'not $MakeAndModel and $XMPToolkit' \
    '-FileName</volume1/media/${FileModifyDate#;DateFmt("%Y/%m/%d")}/EDIT/${FileModifyDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/${CreateDate#;DateFmt("%Y/%m/%d")}/EDIT/${CreateDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/${DateTimeOriginal#;DateFmt("%Y/%m/%d")}/EDIT/${DateTimeOriginal;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    -r '/volume1/footage/PHOTOS' \
    -@ args \
    -common_args -ext jpg


args file

-q
-q
-progress


PH Edit: Use "code" blocks instead of "tt"
Using ExifTool v12.37 on Linux

StarGeek

Ah, got it.

You're not checking to make sure that there is actually a value in your tags before returning them.  So in the case of MyMake and MyModel, they will return a 0 length string.  In the case of MyMakeAndModel, it will return an underscore if neither of the other tags exist, which you are replacing with a space in the command.

Your return statements should be
return $Make ? uc $Make : undef;

return $Model ? uc $Model : undef;

return (MyMake and $MyModel) ? $join '_', $MyMake, $MyModel : undef;


And I would suggest that MyMakeAndModel be changed to Require instead of Desire, which will skip it completely if both tags don't exist
        MyMakeAndModel => {
            Require => {
                0 => 'MyMake',
                1 => 'MyModel'
            },


But this doesn't solve the problem of the entire command failing if any one of those tags don't exists, so you would need another tag
CombinedMakeModel => {
Desire => {
0 => 'MyMake',
1 => 'MyModel',
2 => 'MyMakeAndModel',
ValueConv => q{
my @RetArr= ();
push (@RetArr, $val[0]) if (defined $val[0]);
push (@RetArr, $val[1]) if (defined $val[1]);
push (@RetArr, "$val[2]) if (defined $val[2]);
return @RetArr? \@RetArr:undef;
},
},


"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

J4c06r1nw1s

Thank you.  :) Learned a lot again.
Still have to study it carefully.
Using ExifTool v12.37 on Linux

J4c06r1nw1s

#7
Another question.

Instead of:

-if 'not $XMPToolkit' \
    '-FileName</volume1/media/ ... .%e' \
-if '$XMPToolkit' \
    '-FileName</volume1/media/EDITED/ ... .%e' \

Do I have this now:

${XMPToolkit;s/.+/EDITED/}
[/tt]
Is this a smart way or can it be done better?

[tt]
exiftool \
-config config \
    -o . \
    '-FileName</volume1/media/${FileModifyDate#;DateFmt("%Y/%m/%d")}/${FileModifyDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/${CreateDate#;DateFmt("%Y/%m/%d")}/${CreateDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/${DateTimeOriginal#;DateFmt("%Y/%m/%d")}/${DateTimeOriginal;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/$MyMake/$MyModel/${FileModifyDate#;DateFmt("%Y/%m/%d")}/${MyMakeAndModel}_${FileModifyDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/$MyMake/$MyModel/${CreateDate#;DateFmt("%Y/%m/%d")}/${MyMakeAndModel}_${CreateDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/$MyMake/$MyModel/${DateTimeOriginal#;DateFmt("%Y/%m/%d")}/${MyMakeAndModel}_${DateTimeOriginal;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/${FileModifyDate#;DateFmt("%Y/%m/%d")}/${XMPToolkit;s/.+/EDITED/}/${FileModifyDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/${CreateDate#;DateFmt("%Y/%m/%d")}/${XMPToolkit;s/.+/EDITED/}/${CreateDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/${DateTimeOriginal#;DateFmt("%Y/%m/%d")}/${XMPToolkit;s/.+/EDITED/}/${DateTimeOriginal;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/$MyMake/$MyModel/${FileModifyDate#;DateFmt("%Y/%m/%d")}/${XMPToolkit;s/.+/EDITED/}/${MyMakeAndModel}_${FileModifyDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/$MyMake/$MyModel/${CreateDate#;DateFmt("%Y/%m/%d")}/${XMPToolkit;s/.+/EDITED/}/${MyMakeAndModel}_${CreateDate;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    '-FileName</volume1/media/$MyMake/$MyModel/${DateTimeOriginal#;DateFmt("%Y/%m/%d")}/${XMPToolkit;s/.+/EDITED/}/${MyMakeAndModel}_${DateTimeOriginal;DateFmt("%Y%m%d%H%M%S")}_${ImageSize}%+c.%e' \
    -overwrite_original \
    '-KeyWords<CombinedMakeModel' \
    -r '/volume1/footage/PHOTOS'


PH Edit: Use "code" blocks instead of "tt"
Using ExifTool v12.37 on Linux