I have the following Bash script. It looks for pictures in 3 (or more) directories.
#!/bin/sh
declare -a ext=(".tga" ".jpg" ".png")
declare -a directory=(
"../Untitled.ed.tga/" "../Untitled.ed.jpg/" "../Untitled.ed.png/")
for ((ctDir=0; ctDir<${#directory[@]}; ctDir++));
do
#get number of Pix in each Dir
cd ${directory[${ctDir}]}
let numPixInDir[${ctDir}]=$(
bc <<< " $( ls *${ext[${ctDir}]} | wc -l) " )
let "f = numPixInDir[${ctDir}]"
echo "f == ${f}"
echo "numPix == ${numPixInDir[${ctDir}]}"
done
for ((ctN=1; ctN<=${f}; ctN++));
do
for ((ctDir=0; ctDir<${#directory[@]}; ctDir++));
do
printf "%05d\t" ${ctN}
done
printf '\n'
done
The above does what I want, provided the dirs have the same number of files, but if I set the variable ${f} to an array for each of the directories -
let "f[${ctDir}] += numPixInDir[${ctDir}]"
Then the first for loop raises error:
((: ctN<=: syntax error: operand expected (error token is "=")
Anyone figure how I can do this successfully?