ExifTool Forum

ExifTool => Archives => Topic started by: Archive on May 12, 2010, 08:54:24 AM

Title: Problems renaming using caption-abstract
Post by: Archive on May 12, 2010, 08:54:24 AM
[Originally posted by darryl on 2008-09-04 07:46:02-07]

Hi:

I'm on Windows XP with ExifTool 7.41, and I'm trying to rename a
file based on its caption.  They're kids names, like Zach Smithee
and Troy Calviness.

Captions were set using IrfanView Thumbnails.

So I'm doing:

Code:
exiftool "-filename<${caption-abstract}.jpg" IMG_*.jpg

Unfortunately I end up with the following files:
"Zach Smithee", "Troy Calviness.jpg"

So, in one case, the extension does not properly get set.

As a test, I also did:

Code:
exiftool "-filename<${caption-abstract}.%e" IMG_*.jpg

Exact same results.

When I run exiftool against the files to just dump the contents, I see
no linefeeds in Zach's photo.  When I look at their IPTC Information
in IrfanView Thumbnails, I see no linefeeds.

Tested in Linux w/ 7.30 and ugh, of course, no problems.

Any ideas why Windows is sucking?

Thanks!!

--Darryl
Title: Re: Problems renaming using caption-abstract
Post by: Archive on May 12, 2010, 08:54:24 AM
[Originally posted by exiftool on 2008-09-04 10:52:49-07]

Hi Darryl,

It is likely there are some odd characters in the caption that
Windows doesn't like.  (I think your instinct about linefeeds
was a good one, but there are other characters that could
cause problems too.)  Try using the -v3 option to see exactly
what the caption-abstract contains.  If this is the problem,
you could consider creating a user-defined tag to filter out
the bad characters and reformat the filename if necessary.

- Phil
Title: Re: Problems renaming using caption-abstract
Post by: Archive on May 12, 2010, 08:54:31 AM
[Originally posted by knightbeat on 2009-02-18 11:53:34-08]

Hi Phil,
I'm doing something similar to Darryl's original message - changing the filename based upon Caption-abstract. However, I've found that the element in my images contains a semi-colon and lots of superfluous information. Is it possible to extract a segment of a metadata element through the command line? E.g. specify the start position as the 4th character and that you want to extract 10 characters.

Cheers,
Gareth
Title: Re: Problems renaming using caption-abstract
Post by: Archive on May 12, 2010, 08:54:31 AM
[Originally posted by exiftool on 2009-02-18 12:12:07-08]

Hi Gareth,

You can do this sort of thing with a user-defined tag.
See
this post
for an example.

In your case, extracting the substring could be done with:

Code:
           ValueConv => 'substr($val, 3, 10)',

Or you can use the full power of Perl in this expression to
do whatever else you want.  Perl's regular expressions provide
very powerful text-manipulation abilities.

- Phil
Title: Re: Problems renaming using caption-abstract
Post by: Archive on May 12, 2010, 08:54:31 AM
[Originally posted by knightbeat on 2009-02-19 12:05:51-08]

Thanks for the quick reply. I've configured the config file (based upon your referenced example) to refer to the new tag. However, it won't accept a value. If I enter 'exiftool "-myfirstcustomtag=test" image.tif on the command line I receive a 'sorry, myfirstcustomtag is not writable' message. I've looked at the writable bit in the documentation, but I can't figure out where/if it should appear in the conf file. Do you have any recommendations?

Thanks Gareth
Title: Re: Problems renaming using caption-abstract
Post by: Archive on May 12, 2010, 08:54:31 AM
[Originally posted by exiftool on 2009-02-19 12:28:28-08]

Hi Gareth,

You want to write the filename, not your tag:

Code:
exiftool "-filename<$myfirstcustomtag.jpg" FILE

or something like that.

- Phil
Title: Re: Problems renaming using caption-abstract
Post by: Archive on May 12, 2010, 08:54:31 AM
[Originally posted by knightbeat on 2009-02-19 13:52:29-08]

Hi Phil,
I haven't got to the stage where I need to write the tag to the file yet, though I apologise if my previous post did not provide sufficient detail. I'm still trying to update the myfirstcustomtag with the shortened text from another element. I provide a copy of the conf file below:

%Image::ExifTool::UserDefined = (

    'Image::ExifTool::Composite' =&gt {

        myfirstcustomtag =&gt {

            require =&gt 'description',

            ValueConv =&gt 'substr($description, 3, 10)',

        },

    },

);

print "Config finish\n";

1; #end

If I understand it correctly, the config file should create a new tag (called myfirstcustomtag) and populate it with a subset of text from the Description tag. The configure file loads correctly and the new tag is recognised. However, it doesn't insert the converted description text into the tag. To identify where it goes wrong I tried to insert some dummy text (test) through the command line, which produced the non-writable error seen in my previous message. I'm not sure what needs to be changed to solve the problem, unfortunately. My initial guess was that I had created a tag and restricted it by accident using 'require'. However, changing that line (e.g. to replace require with desire, or replace description with something else) does not produce any results.

Apologies if I am missing something obvious. Do you have any recommendations on what I need to change to insert the shortened description text into the custom tag?
Title: Re: Problems renaming using caption-abstract
Post by: Archive on May 12, 2010, 08:54:31 AM
[Originally posted by exiftool on 2009-02-19 14:01:25-08]

Just two small mistakes:

1) You need "$val", not "$description" in the ValueConv

2) You had the wrong case for 'Require' and 'Description' (case is significant here):

Code:
%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        MyFirstCustomTag => {
            Require => 'Description',
            ValueConv => 'substr($val, 3, 10)',
        },
    },
);
print "Config finish\n";
1; #end

With this config file, you should be able to see the modified Description with
this command line:

Code:
exiftool -myfirstcustomtag FILE

- Phil
Title: Re: Problems renaming using caption-abstract
Post by: Archive on May 12, 2010, 08:54:31 AM
[Originally posted by knightbeat on 2009-02-23 08:40:52-08]

That seems to have solved it. Thanks for your help, Phil.