NewBe

Started by ursus, November 28, 2010, 08:20:52 AM

Previous topic - Next topic

ursus

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.

Phil Harvey

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 has a Basename tag which is the FileName without the extension, and I recently posted an example script in the forum that shows how to translate characters in a tag value.

- 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 ($).

ursus

Thanks Phil fr your answer,

I will try and report back success (or any errors)

Keep well, Ursus

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

Phil Harvey

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 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 for help if you have trouble getting your user-defined tags to work.

- 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 ($).

ursus

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