I would like to do an operation on every .jpg file in a directory. But unfortunately it only works, when I specify the directory and extension hard coded, but as soon as I try to use variables instead, it stops working... So this works:
shopt -s globstar
for FILE in /path/to/my/directory/**/*.jpg do
printf "processing file:%s\n" "${FILE}"
done
and lists all the jpg files in the specified directory. But as soon as I want to introduce variables it stops working. So this does not work:
shopt -s globstar
DIRECTORY="/path/to/my/directory"
EXTENSION="jpg"
for FILE in "${DIRECTORY}/**/*.${EXTENSION}"
do
printf "processing file:%s\n" "${FILE}"
done
as it gives the following output:
/path/to/my/directory/**/*.jpg
instead of multiple printf calls with different paths. So what did I do wrong here and do I have to use the find command when working with variables?