Conditional renaming

Started by Fluff, February 21, 2016, 06:50:05 AM

Previous topic - Next topic

Fluff

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

Fluff

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!

Hayo Baan

Try -Filename<${IPTC:Headline;s/\/.*//;lc}.%e
lc will make everything lowercase. Use uc to make everything uppercase.
Hayo Baan – Photography
Web: www.hayobaan.nl

Fluff

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?

Phil Harvey

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

Fluff

And it works!!

Thank you Phil, I understand.