Try sending the output of the 'for' substitution to a file and see if it looks right.
I've been looking at the manual pages for 'for,' but haven't gotten far enough to see if your syntax is what you need.
Off topic: Awk, grep, VBA, C, AutoIT, FORTRAN, Postscript; these I get, but not windows command scripting. I think the goofy things like use % if you type it, but %% if it's in a batch file - for the same result - is what makes it hurt to read.