Formatting the output when using -Directory<TAG

Started by Liberty-Joe, February 03, 2017, 06:11:54 AM

Previous topic - Next topic

Liberty-Joe

Hi everyone !

First, thanks to everyone who are involved in the development of exiftool and / or in the life of the forum. It can seem obvious but all of you allow people like me to create things with few intellectual, financial and human ressources.

I've got a problem that I am struggling with since a week.

I am using exiftool "-Directory<LightValue" dir to move all files into directories named by their light value.

I get directories with names like : 8.3, 9.9, 12.3. But I need to sort the directories alphabetically so  I need value like 08.3, 09.9, 12.3 etc...

So how can I put a 0 before the value < to 10 ?
If it's not possible from -directory,TAG, how can I change the LightValue in the exif of the pictures to put a 0 before the value ?

I have to precise that it will be used into a .bat file.

Thank you and sorry for my English.


 

Phil Harvey

Try this:

exiftool "-directory<${lightvalue;$_=sprintf('%04.1f',$_)}" DIR

(but in a .bat file you will need to change "%" to "%%")

or this:

exiftool "-directory<${lightvalue;s/^(\d\.)/0$1/}" DIR

(as usual, there is more than one way to do it -- TIMTOWTDI)

Either of these should work unless you have pictures that are shot at REALLY low light levels (-10EV or lower), although the negative values will sort in reverse order.

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

Liberty-Joe

The two solutions are working well.

Thank you very, very much Phil.

You give the software, the manual, cristal clear and very fast answer to any questions.

Very impressive, I'll remember it.