ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: Fluff on February 21, 2016, 06:50:05 AM

Title: Conditional renaming
Post by: Fluff on February 21, 2016, 06:50:05 AM
Hello all,

I'm a searching a way to rename a jpg file, with a name based of my IPTC:Headline tag.

Where it add a bit of complexity, is that my IPTC:Headline is of that form : image name in french/image name in english.
What I want to do is to obtain a filename like image-name-in-french.jpg.

I've tried something like this : exiftool -filename<${IPTC:Headline;}.%e
but the semicolon only remove the /. I would like to find something to remove the portion of the IPTC:Headline tag value after the /. I don't see at that time a way to do that.

Any idea?

Thank you by advance
Title: Re: Conditional renaming
Post by: Fluff on February 21, 2016, 08:33:31 AM
Ok, I tryed this and it seems to work :

-Filename<${IPTC:Headline;s/\/.*//}.%e

Now I would like to turn all uppercase letters in my filename into lowercase. Is there a way?

Thank you!
Title: Re: Conditional renaming
Post by: Hayo Baan on February 21, 2016, 01:06:15 PM
Try -Filename<${IPTC:Headline;s/\/.*//;lc}.%e
lc will make everything lowercase. Use uc to make everything uppercase.
Title: Re: Conditional renaming
Post by: Fluff on February 22, 2016, 03:09:28 PM
Well, thank you Hayo, but it doesn't work.
I'm trying to find how to use the "lc" commande, but don't see... If you have an idea?
Title: Re: Conditional renaming
Post by: Phil Harvey on February 22, 2016, 04:03:58 PM
Just one minor change and this should work: -Filename<${IPTC:Headline;s/\/.*//;$_=lc}.%e

You must assign the lc value back to $_ to actually change the value.

- Phil
Title: Re: Conditional renaming
Post by: Fluff on February 22, 2016, 04:06:57 PM
And it works!!

Thank you Phil, I understand.