为什么这个bash脚本会创建一个新目录?

我是使用bash脚本的新手(在过去的几个小时中,我只是作为一个较大的项目的一部分来学习它),并且我试图理解bash脚本中的这段代码:

for newDir in `cat tempfile.list` ; do
        dir=/Tree/Apples/$newDir
        [ -d $dir ] || mkdir -p $dir/{log,err}
done

What does [-d $dir] do? And does this code create a new directory named dirName within the Apples directory? If so, why does it do that? I don't see a statement that says mkdir dirName. Can someone please explain in general what the statement [ -d $dir ] || mkdir -p $dir/{log,err}does? Thank you very much for your help!