Move Images with Particular Dimension to Subfolder

Started by rodertroy, September 03, 2020, 03:42:40 PM

Previous topic - Next topic

rodertroy

In the following bash script I don't know where to place the variable "$dimension". I want to use the variable in place of "> 800", so that I can specify at the CLI prompt what images greater or smaller I want moved to a subfolder. I've tried inserting it various places with no luck.

#!/bin/sh


echo "Please type Dimension and press enter"
read dimension

if [ -z "$dimension" ]; then
printf "no caption was selected, aborting!\n"
exit 1
fi
printf "dimension is $dimension\n"

exiftool -q -r -ext jpg -if '$ImageHeight > 800' -p '$Directory/$FileName' . -Directory=exiftool

StarGeek

Use double quotes around it so it's treated as a Bash variable instead of an exiftool one.  See this post, though that's a bit more complex. Also this post.

I think something like this might work, though I'm not sure because I can't test it out on Windows.
-if '$ImageHeight >'"$dimension"
or maybe
-if '$ImageHeight >'"${dimension}'"
* 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).

rodertroy

When I try both your suggests it just places a file called "dimensions" in the working directory.

I'm using Windows Subsystem for Linux (which uses Ubuntu). My other exiftool bash scripts work fine using WSL.

I'll check out the links, tx.

rodertroy

Actually I tried your suggestion again and it worked!

This is the code:

#!/bin/sh

echo "Please type Dimension and press enter"
read dimension

if [ -z "$dimension" ]; then
printf "no caption was selected, aborting!\n"
exit 1
fi
printf "dimension is $dimension\n"

exiftool -q -r -ext jpg -if '$ImageHeight >'"$dimension" -p '$Directory/$FileName' . -Directory=exiftool

$SHELL