ExifTool Forum

ExifTool => ExifTool GUI => Topic started by: cartelpix on October 03, 2012, 02:40:12 PM

Title: Filename without extension put to..
Post by: cartelpix on October 03, 2012, 02:40:12 PM
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
Title: Re: Filename without extension put to..
Post by: Phil Harvey on October 03, 2012, 02:53:53 PM
Hi Thomas,

You need to create a user-defined tag to do this.  See the "BaseName" example in the sample config file (https://exiftool.org/config.html) for how to do this.

- Phil
Title: Re: Filename without extension put to..
Post by: cartelpix on October 03, 2012, 02:59:52 PM
Thx Phil.
I'm not an expert so I need some time to understand the proposed solutions.
Thomas
Title: Re: Filename without extension put to..
Post by: cartelpix on October 03, 2012, 04:59:35 PM
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)
Title: Re: Filename without extension put to..
Post by: Phil Harvey on October 04, 2012, 07:10:57 AM
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
Title: Re: Filename without extension put to..
Post by: cartelpix on October 04, 2012, 02:40:04 PM
Rock'n'Roll. Thanks for your advice.
/T.