Hi Phil Harvey
Is it possible to declare a read-only tag if it already exists?
query: exiftool.exe -s2 -G0:1 -XMP-creyskull:OriginalFileName P4038088.jpg
result: (undef)
set: exiftool.exe -s2 -G0:1 "-XMP-creyskull:OriginalFileName<FileName" P4038088.jpg
result: 1 image files updated
query: exiftool.exe -s2 -G0:1 -XMP-creyskull:OriginalFileName P4038088.jpg
result: [XMP:XMP-creyskull] OriginalFileName: P4038088.jpg
My request:
set again: exiftool.exe -s2 -G0:1 "-XMP-creyskull:OriginalFileName<FileName" P4038088.jpg
Warning: Sorry, xmp-creyskull:OriginalFileName is not writable - P4038088.jpg
Warning: No writable tags set from P4038088.jpg
0 image files updated
1 image files unchanged
My ExifTool_config file:
%Image::ExifTool::UserDefined = (
'Image::ExifTool::XMP::Main' => {
creyskull => {
SubDirectory => {
TagTable => 'Image::ExifTool::UserDefined::creyskull',
},
},
},
);
%Image::ExifTool::UserDefined::creyskull = (
GROUPS => { 0 => 'XMP', 1 => 'XMP-creyskull', 2 => 'Image' },
NAMESPACE => { 'creyskull' => 'http://ns.creyskull.com/photo/1.0/' },
WRITABLE => 'string',
OriginalDateTime => {
Writable => 'date',
},
OriginalMD5 => {
ValueConvInv => q{
return $val if $val =~ /^[0-9a-f]{32}$/i;
warn "OriginalMD5 must be Digest::MD5" . $val . "\n";
return undef;
},
},
OriginalFileName => {
},
);
This can be done for any tag (not just user-defined tags) by using the conditional replace feature:
exiftool -XMP-creyskull:OriginalFileName-= "-XMP-creyskull:OriginalFileName<FileName" P4038088.jpg
In this command, the tag will be replaced only if it didn't previously exist.
Also, I should mention that the -s2 -G0:1 options have no effect when writing.
- Phil
Edit: Re-reading your post, I'm not 100% sure this is what you wanted. To create a true read-only user-defined tag, set "Writable => 0," in the config file. But if you do this, you won't be able to write it the first time.
Thanks, the conditional replace feature ( -= ), should be enough for me.
The -s2 -G0:1 option is only for a better view for me. :)
---------------------------------------
one more question:
As can be seen in the UserDefined, retrieve values?
The following does not work unfortunately
ValueConvInv => q{
my $oldName = $Image::ExifTool::XMP::creyskull::OriginalFileName;
******
Quote from: cocteau on February 09, 2012, 08:54:42 AM
As can be seen in the UserDefined, retrieve values?
The following does not work unfortunately
ValueConvInv => q{
my $oldName = $Image::ExifTool::XMP::creyskull::OriginalFileName;
******
No. The ValueConvInv is executed before any files are processed, so there is no way to access the original value at this time. But there are probably other ways to do what you want, if I knew what you were trying to do.
- Phil
I want to compare before and after.
My Problem with, the conditional replace feature
Step1:
query: MD5.exe -n P1094893.XMP
result: 5C7F1120614B953E613608ED13A53257
Step2:
set: exiftool.exe -XMP-creyskull:OriginalFileName-= "-XMP-creyskull:OriginalFileName<FileName" P1094893.XMP
result: 1 image files updated
Step3:
query: MD5.exe -n P1094893.XMP
result: A93C98879DA540EEA91F5E1DF1EFA4E2
Step4:
set again: exiftool.exe -XMP-creyskull:OriginalFileName-= "-XMP-creyskull:OriginalFileName<FileName" P1094893.XMP
result: 1 image files updated
Step5:
query: MD5.exe -n P1094893.XMP
result: A93C98879DA540EEA91F5E1DF1EFA4E2
Why in Step 4, the file is changed? Because the checksum is the same (Step3 <> Step5) !
--------------------------------------------------------------
Sorry for my english, google translate
Ooops. You're right. Sorry. The implied -tagsFromFile overrides the conditional replacement. Try this instead:
exiftool.exe -XMP-creyskull:OriginalFileName-= -addtagsfromfile @ "-XMP-creyskull:OriginalFileName<FileName" P1094893.XMP
- Phil
I tested it with my batch and works well. big thank you
set exiftool.exe -@ "%WORK%SET_CREYSKULL.txt" "-XMP-creyskull:OriginalMD5=%xMD5%" "-XMP-photoshop:Source=%xMD5%" "%~1"
SET_CREYSKULL.txt :
-ignoreMinorErrors
-charset
iptc=UTF8
-XMP-xmpMM:PreservedFileName-=
-XMP-crs:RawFileName-=
-XMP-dc:Title-=
-XMP-creyskull:OriginalFileName-=
-XMP-creyskull:OriginalDateTime-=
-XMP-creyskull:OriginalType-=
-XMP-creyskull:OriginalMD5-=
-XMP-photoshop:Source-=
-addtagsfromfile
@
-XMP-xmpMM:PreservedFileName < FileName
-XMP-crs:RawFileName < FileName
-XMP-dc:Title < BaseName
-XMP-creyskull:OriginalFileName < FileName
-XMP-creyskull:OriginalDateTime < DateTimeOriginal
-XMP-creyskull:OriginalType < FileType
an the %xMD5% is the MD5 Checksum Variable
-----------------------------------------------------------------------
Is a "small" problem with it XMP < bag > items (same duplicate values in XMP-iptcExt:ArtworkTitle), but I have to look at it again in peace.
I should have mentioned this. The -= has a different effect for list-type tags (XMP "bag" items). For these, items are added and deleted individually, so the syntax won't work to only add items if none existed before. The simplest work-around for these would be to use a -if condition and write these separately, but this would have a performance impact because then you'd need to process the file separately for each list-type tag. If this is a problem, maybe I can come up with a better solution.
- Phil