is there a way to "split" the value of string line readed by a batch file ? Suppose to have this text file
192.168.1.2; PC_NAME_1
192.168.1.3; PC_NAME_3
...
I would like to read line 1, and split the value into two variables ... So i can use IP address, and also, Pc Name (for other purpose)... for example:
for /f %%x in (txtfile.txt) do ( ....
Thanks
Yes, this can be done. A special FOR syntax is used
That'll split it just on a comma. But by default it'll split on space and tab. the 'tokens' term can specify how many of those you want to deal with
In this case %D will contain everything from the fourth delim and beyond.
The thing to keep in mind, though, is that "Do" is not a procedure block, it's a one-off call. This is where "goto" or "call" can be used to invoke further logic. My examples above call another batch-file and pass in the needed parameters as command-line options, so for those subbatch files the variables will be on %1 and %2.