Kyrie, you may have eliminated these possibilities already, but various minor departures from the expected syntax of the set command may produce this error. I do not see such departures in the script you posted here, but clearly it was edited for posting (you don't actually have a directory called 'abunchofdirectories', right?).
Things that would produce such error are missing one (but not both) of the spaces around the '=' sign in the set datapath or set output commands. Or doing the same in the set sublist command if parentheses were NOT used on the right (I think they are not necessary there).
Or mistakenly placing a space before trailing / in the directory name. Stuff like that.