|I have a file that has 10 strings, each separated by commas (no returns). I am trying to get each of the separate strings (between the commas) to be assigned to a seperate variable labeled string.1,string.2,string.3, and so forth. I used a for loop with 10 tokens and setting the delimiters to a comma. I used the variable %%1, so that the different values are stored to %%1,%%2,%%3, etc. Rather than go through the process of doing something like:|
etc., I figured it would be easier to have another for loop inside. This is what I have so far:
for /f "tokens=1,2,3,4,5,6,7,8,9,10 delims=," %%1 in (Strings.txt) do (
for /l %%X in (1,1,10) do (
The idea is that it will set String.1 equal to %%1, and do the same with all the others. However, instead, it sets String.1's value to "%1", and not the first string from the file. If I tell String.1 to equal %%1 and not %%%%X, even within the other for loop, it works, so the problem is not that the variables from the outer for loop do not work in the inner one.
Can anyone tell me what I could do about this? I realize that I could probably do this more easily by just having String.1=%%1, String.2=%%2, etc. but I might decide to make the list longer, and if I do, then it will just be too long.
Another easier solution that may not work would be to store the entire text file to a variable. If there is a function to find the position of a character in a variable, then then I could use that to split the variable into different parts by finding commas. I do not know if there is one, however, but if there is, could someone please tell me what the syntax is?