Renaming based on orientation

Started by Grantson, August 30, 2018, 06:28:35 PM

Previous topic - Next topic

Grantson

Hi Guys

I'm using exiftool to rename by date with a copy number.
I'm looking to add an H or a V to the end of the filename if they are horizontal or vertical

exiftool.exe -d %H.%M-%S%%-c.%%e "-filename<CreateDate" c:\testimages

I tried using step 7 from this to see if i could adapt it but couldn't get it to run properly/recognize the arguments

Any help hugely appreciated

Grant   

StarGeek

Just for clarification, do you mean you want to know if they are Landscape (wider than it is tall) or Portrait (taller than it is wide) shots, or if the orientation has to be rotated to look at them correctly.  What if it is a Portrait shot that needs to be rotated to be viewed properly?

If you just want to know if it's wider than it is tall reguardless of the Orientation tag, then you can use this
${ImageSize;m/(\d+)x(\d+)/; $_= ($1>=$2)?'H':'V'}

But you'll have to change the command a bit to accommodate it.  The %e has to be moved and in doing so, the % sign doesn't need to be doubled.  Also added a $ to CreateDate.
exiftool.exe -d %H.%M-%S%%-c "-filename<$CreateDate${ImageSize;m/(\d+)x(\d+)/; $_= ($1>=$2)?'H':'V'}.%e" c:\testimages

To take into account the orientation flag would be more complex.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Grantson

Thanks StarGeek

I've just run this on my test directory and its just added an H to everything.
I assume everything is showing  4752x3168 and being adjusted by windows to show in the correct orientation in explorer?

Ill keep reading & playing 

Phil Harvey

OK, so you should be testing the Orientation tag then, and not the ImageSize.

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

StarGeek

Try
exiftool.exe -d %H.%M-%S%%-c "-filename<$CreateDate${Orientation; $_= ($_=~/(Horizontal \(normal\)|Rotate 180)/)?'H':'V'}.%e" c:\testimages

I think that will work.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).