Filename without extension put to..

Started by cartelpix, October 03, 2012, 02:40:12 PM

Previous topic - Next topic

cartelpix

I want to put the filename without the extension in the cell, eg ImageDescription.
File Name: "sample.jpg"
An ideal data entered ImageDescription "sample"

I tried:
-ImageDescription<$filename
-Exif:DocumentName<$filename
but that is because he is not satisfied with .jpg

I tried with: -w% 6f
.. but do not know where to enter.

Thank you in advance for your help.
Thomas

Phil Harvey

Hi Thomas,

You need to create a user-defined tag to do this.  See the "BaseName" example in the sample config file for how to do this.

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

cartelpix

Thx Phil.
I'm not an expert so I need some time to understand the proposed solutions.
Thomas

cartelpix

With this config file:

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        GO => {
            Require => {
                0 => 'FileName',
            },
            ValueConv => 'my $name=$val[0]; $name=~s/\..*?$//; $name',
        },
   },
);
1; # end


and this command:
-ImageDescription<GO

How to define that the name was truncated to, eg 6 characters? (no matter how long it will last)

Phil Harvey

The ValueConv you have there removes the extension from the file name.  There are various ways to truncate to 6 characters.  Here is one:

    ValueConv => '$val=~/(.{1,6})/; $1',

here is another:

    ValueConv => 'length($val) > 6 ? substr($val,0,6) : $val',

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

cartelpix

Rock'n'Roll. Thanks for your advice.
/T.