Question: Suppose I have a string "AAA BBB CCC DDD EEE FFF".

How can I split the string and retrieve the nth substring, in a batch file?

The equivalent in C# would be

```
"AAA BBB CCC DDD EEE FFF".Split()[n]

```

Answer: 
This is the only code that worked for me:

```
for /f "tokens=4" %%G IN ("aaa bbb ccc ddd eee fff") DO echo %%G 

```

output:

```
ddd

```
you can use vbscript instead of batch(cmd.exe)

```
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
str1 = objArgs(0)
s=Split(str1," ")
For i=LBound(s) To UBound(s)
    WScript.Echo s(i)
    WScript.Echo s(9) ' get the 10th element
Next

```

usage:

```
c:\test> cscript /nologo test.vbs "AAA BBB CCC"

```