on my laptop running KDE I would like to have a list with the exif metatag orientation for each picture,
if I make an executable file with this inside:
Hi hui, yes, for this I’m asking help, may be an if statement could help me, for example a script
with:
if orientation is blank
then echo blank
else orientation tag
fi
but I’m not able to translate this in bash script
You could at least do a ls -l <that file>
so we can see the name (makes it easy to talk about it and to see when you execute it) and also that it is indeed what you say.
And you could at least show what the output is from
the files “file.orientation1.jpg” and “file.orientation2.jpg” have output=Orientation : Rotate 180 output
the file “file.noorientation1.jpg” has nothing as output
I am very unsure about what the first code sections shows, so I will skip to interpret it.
Well, it seems that you have files there owned by “root” and group “users”. A very strange combination.
But the second section shows that there is indeed no output at all.
For a script, you could first catch the output:
RESULT="$(exiftool -orientation <file.jpeg>)"
and then test on emptiness
if [[ -z ${RESULT} ]]
then echo "no orientation specified"
else echo "${RESULT}"
fi
And you still did not answer my first questions: what is the file name of your script!
manythanks hcvv
first the name of my script is
"foto-0orient(something depends on the test) .txt "
and to launch it I use
~/bin/foto-comments> ./foto-0orient(something depends on the test) .txt "
your script, modified with file name, gives me some errors:
this is the script
#!/bin/bash
RESULT="$(exiftool -orientation exiftool -orientation "/dati/a-FOTO-x-amici/2013/2013-12-31dic(foto scrive sopra)/file.orientation1.jpg")"
if [[ -z ${RESULT} ]]
then echo "no orientation specified"
else echo "${RESULT}"
fi
RESULT="$(exiftool -orientation exiftool -orientation "/dati/a-FOTO-x-amici/2013/2013-12-31dic(foto scrive sopra)/file.noorientation1.jpg")"
if [[ -z ${RESULT} ]]
then echo "no orientation specified"
else echo "${RESULT}"
fi
RESULT="$(exiftool -orientation exiftool -orientation "/dati/a-FOTO-x-amici/2013/2013-12-31dic(foto scrive sopra)/file.orientation2.jpg")"
if [[ -z ${RESULT} ]]
then echo "no orientation specified"
else echo "${RESULT}"
fi
fi
RESULT='$(exiftool -orientation exiftool -orientation "/dati/a-FOTO-x-amici/2013/2013-12-31dic(foto scrive sopra)/file.orientation2.jpg")'
if [[ -z ${RESULT} ]]
then echo "no orientation specified"
else echo "${RESULT}"
fi
this is the output
pla@pla4-TW:~/bin/foto-comments> ./foto-0orientif2.txt
Error: File not found - exiftool
======== /dati/a-FOTO-x-amici/2013/2013-12-31dic(foto scrive sopra)/file.orientation1.jpg
Orientation : Rotate 180
Orientation : Rotate 180
1 image files read
1 files could not be read
Error: File not found - exiftool
======== /dati/a-FOTO-x-amici/2013/2013-12-31dic(foto scrive sopra)/file.noorientation1.jpg
1 image files read
1 files could not be read
Error: File not found - exiftool
======== /dati/a-FOTO-x-amici/2013/2013-12-31dic(foto scrive sopra)/file.orientation2.jpg
Orientation : Rotate 180
Orientation : Rotate 180
1 image files read
1 files could not be read
pla@pla4-TW:~/bin/foto-comments>
but you led me towards something that seems to works
this is the script
As hui already found out. This is complete nonsense.
Are you even trying to understand the hints I gave. I do not hint you so that you malform and mis-use it. It do so that you at least try to understand the commands and the constructs. By reading e.g. your bash course material and the man page. And when you fully understand what things mean, then you will be able to use them for your case.