For (/F) Loop in Batch File Programming

preview_player
Показать описание
In this tutorial, we have discussed about For /F loop and different options like delims, skip, eol, token and usebackq with examples.

the syntax for this loop is like
FOR /F ["options"] %%parameter IN (filename) DO command
FOR /F ["options"] %%parameter IN ("Text string to process") DO command

options:
delims= The delimiter character(s) (default = a space)
skip=n A number of lines to skip at the beginning of the file. (default = 0)
eol=; Character at the start of each line to indicate a comment The default is a semicolon ;
tokens=n Specifies which numbered items to read from each line (default = 1)
usebackq Use the alternate quoting style:
- Use double quotes for long file names including spaces in "filename".
- Use single quotes for 'Text string to process'
- Use back quotes for `command to process`

tokens=1,2,3 will cause the first, second and third items on each line to be processed.

tokens=1-3 will cause the 1-3 items on each line to be processed.

tokens=* will cause all items on each line to be processed.

tokens=2* will process the third token and the 4th + all subsequent items, this can also be written as tokens=2,*

Please share and subscribe the video and for any doubt please comment in the comment section.
Рекомендации по теме
Комментарии
Автор

You sir are a gift from heaven. I love you so much. Thanks a lot!

enderezjaroldadrian
Автор

For command options were so confusing until now! Thank You so much!!

joshuapearce
Автор

Rakesh, How to read only one line at a time? After reading first line then execute some commands and then read second line.. and the loop goes on

KunisettyKartheek
Автор

Thanks!!! It is very helpful tutorial.

damhi
Автор

Dear Sir,
I am dealing with for /f to insert a new line with specific text in a txt file in a specific location just below all the same word.
I am wondering if you could help me. If you like I can send you my code with the txt files.
thanks in advance
Miguel

miguelsomma
Автор

How to save these values in a particular variablr

mahendrasinghbaghel
Автор

Hi. How can I extract a Default Gateway from "ipconfig" (but I just want the IP). Ex: 192.168.0.1
Can u help me?

viniciussilveira
Автор

Turn off the music when you want to show something

unsal
Автор

Very nice
Can you plz provide batch file to copy those txt file which contain string VABJ in second line of the text of the files where files are there in one other folder say
Source folder is E:/test
Destination folder is D:/result
Plz provide batch file for this

SUBHASHKUMAR-lbyg
Автор

Thanks!!! It is very helpful tutorial.

swbharatbansal