Q:

Shell - Execute imagemagic for all files in directory and store result

I need to execute next imagemagick command
convert some_image.jpeg logo: -fuzz 0% -negate -threshold 0 -negate -format "%[fx:100*mean]" info:

for all jpeg images inside some directory. The command above will return the percentage number (like 95.922983.4128). I need to compare that number to some threshold (say 98%) and if the percentage is greater than the threshold - move file to another directory.
Currently what I have is:
for filename in /writeData/TAX1040/*.jpeg; do
    white=$(convert $(filename) logo: -fuzz 0% -negate -threshold 0 -negate -format "%[fx:100*mean]")
    echo -n "$white"
done

And I have a missing an image filename error.
Thanks to @oliv I have a working script:
#!/usr/bin/env bash
mkdir -p /writeData/TAX1040/blank

for filename in /writeData/TAX1040/*.jpeg; do
    white=`convert $filename logo: -fuzz 0% -negate -threshold 0 -negate -format "%[fx:100*mean]" info:`

    p=${white:0:2}

    if [ "$p" -ge 98 ]; then
        echo "Percentage of white in file $filename is $p"
        echo "Moving file $filename to blank directory"
        mv "$filename" /writeData/TAX1040/blank
    fi
done

A:

The file must be used with "$filename" instead of $(filename) that actually executes the command filename (which is likely to fail).
Assuming that you convert command line is correct, you can then perform your check on the value like this:
threshold=98
for filename in /writeData/TAX1040/*.jpeg; do
  white=$(convert "$filename" logo: -fuzz 0% -negate -threshold 0 -negate -format "%[fx:100*mean]")
  if(( white > threshold )); then
     mv "$filename" /to/another/path
done

Note that in a arithmetic expression ((...)) you don't need to use the $ for the expansion.

