I felt it was better to ask this separately rather than expect an answer from my comment on my previous post.
I already have variables set for the directory number
dir d09854* /b
will recover the full folder name in one line, without the extra cruft, if that's any use? What are you writing this widget in?
Does it have to be Good Old Fashioned DOS, or can the newer Command extensions be used?
With limited old DOS, I can't think of a way to get that into a SET Variable without piping it to a temporary batch file, having first ECHO'd a set variable=
into it, and using >> in the pipe to append to it... and then CALL the temporary batch file to execute the command!