Hi,
I want to use the "find" command to look for text, and then set that result as a variable.
Can you do that?
If you can, then can you show me how to do so?
Any help would be appreciated.
Regards,
Rileyh
How to use "find" results as variables
Moderator: DosItHelp
Re: How to use "find" results as variables
You have to use a FOR /F loop. But it's not enough information to give you detailed help.
Regards
aGerman
Code: Select all
for /f "delims=" %%i in ('find "string" "file.txt"') do set "var=%%i"
Regards
aGerman
Re: How to use "find" results as variables
aGerman,
What I want to do is look for text, and if the text that is found AND it matches another piece of text, do a command.
And could you provide an example and explanation of what a "for /f" loop is?
Any help would be appreciated,
Rileyh
What I want to do is look for text, and if the text that is found AND it matches another piece of text, do a command.
And could you provide an example and explanation of what a "for /f" loop is?
Any help would be appreciated,
Rileyh
Re: How to use "find" results as variables
No idea what exactly you are looking for, but you should have a look at the help of find (find /?) and findstr (findstr /?).
Type for /? in the command window and hit Enter to get more info or have a look at the Command Index.
Regards
aGerman
Type for /? in the command window and hit Enter to get more info or have a look at the Command Index.
Regards
aGerman
Re: How to use "find" results as variables
aGerman,
Thank you for the advice.
I tried "for /?" in cmd but it is far to complex text for me to understand.
Also, the examples provided relating to text search and looking for strings is very little and with no explanation.
Could you provide me with an explanation of for /f "tokens" and "delims=" please? (I can't get my head around it!!!)
Thank you for your time and effort,
Rileyh
Thank you for the advice.
I tried "for /?" in cmd but it is far to complex text for me to understand.
Also, the examples provided relating to text search and looking for strings is very little and with no explanation.
Could you provide me with an explanation of for /f "tokens" and "delims=" please? (I can't get my head around it!!!)
Thank you for your time and effort,
Rileyh