No space around = allowed in an assignment.
dir="${file%%.*}"
Conversely, a space is required in the test.
if [ -e $dir ]; then ^ ^
As for stylistic improvements, you don't need to make unnecessary mkdir -p , so you can get rid of the if .
Quotes are not required at the time of assignment, so you can remove them from the dir= . Quote is a good idea everywhere, but do not remove other quotation marks.
It might be useful to add an extra .* for loop. Thus, if you run the script more than once, it will not try to move these newly created subdirectories. And the neat trick (though not necessarily an improvement) is to reduce BR*.* W0*.* To {BR,W0}*.* .
for file in {BR,W0}*.*; do dir=${file%%.*} mkdir -p "$dir" mv "$file" "$dir" done
source share