![]() If I wanted to, I could set all the variables, then just echo %a %c %e, resulting in “How you today?” The batch file sets the first variable defined (%a) then will move on to the next one, in this case %b. Still using space as a delimiter, we can grab it with tokens 3-7.įOR /f 'tokens=3-7 delims= " %%a IN (MyFile.txt) DO ECHO %%a %%b %%c %%d %%e Now let’s say that we want the “How are you doing today?” portion. How will we accomplish that? Using a space as a delimiter (separator) we can grab it with the second token.įOR /f "tokens=2 delims= " %%a IN (MyFile.txt) DO ECHO %%a Now, let’s pretend that we want is the word “World!”. It’s a little difficult to explain, so here’s an example. ![]() Tokens basically tell the batch file where to look to set the variable (%a). ![]() I am constantly hearing people asking “What do tokens and delims mean?”. It might look something like this:įOR /f "tokens=* delims= " %%a IN (MyFile) DO ECHO %%a Quite often when writing a batch file, you will come across a FOR loop. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |