redirect stdout echo command in condition A run in condition B

hi,

I have some problems in my simple script about the redirect echo stdout command inside a condition. Why is the echo command inside the elif still execute in the else command

Here are my simple script

After check on the two diff output the echo stdout redirect is present in two diff outputs.

Thanks for any input..

If it's present in both outputs, then it's taking the first branch in both outputs.

Can you explain it for me..If you dont mine..

It is executing this code block both times:

elif [ -d $location -a -d $pwd1 ];then
echo "######### $location root directory ######### " > "$filename"\ Full\ Path-$date.txt
find "$location" -type f | sed 's/\/mnt\/Data\/Ebooks-Video_Tutorials\///g' | sort | grep -v "$filename" >> "$filename"\ Full\ Path-$date.txt
else