$ 0 0 rm -rf part in there is dangerous, I would leave that out. And just replace it with "mkdir -p $dir/$name"