I have no idea where to start. So I just begin here. I have inherited a hard-disk with 20.000+ jpg's. These are organised in folders and sub (sub) folders. I want to move this collection to a cms with a basic IPTC description. I would like the folder information transferred to the headline. Such that c:\myfolder\my city\my jpg\name.jpg becomes -IPTC:Headline="myfolder my city my jpg". And the name of the file as -IPTC:Objectname="name". I first wrote a little shell (using Filemaker Pro) that parses a line for each image. But this is very slow and seems to render unreliable results, sometimes skipping a file.
I have no experience with perl, worked with Visual basic a long time ago. So I really could do with some help, hints or tricks.
What you want can be mostly accomplished with this command:
exiftool "-iptc:objectname<filename" "-iptc:headline<directory" -r DIR
where DIR is the name of the root image directory. If you want to replace the slashes in the directory name with spaces or remove the extension from the filename you will need to create some user-defined tags to do this. The sample config file (https://exiftool.org/config.html) has a Basename tag which is the FileName without the extension, and I recently posted an example script (https://exiftool.org/forum/index.php/topic,2961.0.html) in the forum that shows how to translate characters in a tag value.
- Phil
Thanks Phil fr your answer,
I will try and report back success (or any errors)
Keep well, Ursus
Probably just didn't understand the concept of the .ExifTool.config file. But here is what i created (and it didn't work)
%Image::ExifTool::UserDefined = (
'Image::ExifTool::Composite' => {
BaseName => {
Require => {
0 => 'FileName',
},
# remove the extension from FileName
ValueConv => 'my $name=$val[0]; $name=~s/\..*?$//; $name',
},
Objectname => {
Require => 'DIR',
# translate spaces to underscores
ValueConv => '$val =~ tr/ / /; $val',
},
},
);
#------------------------------------------------------------------------------
1; #end
the config resides in the exiftool dir. The commandline I used: exiftool "-iptc:objectname<filename" "-iptc:headline<directory" -r "c:\test\foto\2002 03 30"
It did update the foto's physically, but didn't do anything to their IPTC contents.
Thanks in advance for any further assistence
The command will have updated the IPTC with the file and directory name. Since you say it didn't, the software you are using must not be reading the IPTC you wrote. FAQ number 3 (https://exiftool.org/faq.html#Q3) deals with this issue.
There are a few problems with your use of the config file however. Try this instead:
%Image::ExifTool::UserDefined = (
'Image::ExifTool::Composite' => {
BaseName => {
Require => {
0 => 'FileName',
},
# remove the extension from FileName
ValueConv => 'my $name=$val[0]; $name=~s/\..*?$//; $name',
},
MyDirectory => {
Require => 'Directory',
# translate slashes (backward or forward) to spaces
ValueConv => '$val =~ s{\\/}{ }g; $val',
},
},
);
#------------------------------------------------------------------------------
1; #end
with this command line:
exiftool "-iptc:objectname<basename" "-iptc:headline<mydirectory" -r "c:\test\foto\2002 03 30"
See FAQ number 11 (https://exiftool.org/faq.html#Q11) for help if you have trouble getting your user-defined tags to work.
- Phil
I will look deeper into the faq's you have mentioned. For now it seems it does exactly what I wanted. And very fast as well.
Thank you very much!
Keep well, Ursus