If this part of your batch code is inside a for loop or if condition, you need to use delayed environment variable expansion. Open a command prompt window, execute there set /? and read the help pages output now. On Stack Overflow search with [batch-file] delayed expansion and you will find thousands of questions and answers.
And you can't assign output of a command to an environment variable with the method you tried here. You need a for loop for this task. To get help on command for, open a command prompt window, execute there for /? and read the help pages output now. Of course on Stack Overflow there are thousands of questions and answers demonstrating how to assign output of a command to an environment variable using for.
set /?and read the help pages output now. On Stack Overflow search with[batch-file] delayed expansionand you will find thousands of questions and answers.for /?and read the help pages output now. Of course on Stack Overflow there are thousands of questions and answers demonstrating how to assign output of a command to an environment variable using for.