I am working on a "for loop that finds all the drives on a system that match a given criteria and am trying to accumulate the drive letters into a list(string) which I can then pipe to a command which will do something to those drives. I do not use the command prompt every day, so please keep explanations simple. here is the code I have so far;
for %a in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (IF NOT EXIST %a:\evac.txt If EXIST %a:\ SET "targetDR=%targetDR %a:" )
The "SET "targetDR=%targetDR %a:" )" is not working as it should. I want the code to accumulate like so;
"C:\ D:\ E:\ F:\" provided the drives match the if statements I have preceding the code. "echo %targetDR%" yields "%targetDR H:" which is incorrect. I will NOT be running this code in a batch file, I will be running it directly from the command prompt. Also, I am not very familiar with variable operations in the command prompt, because in some code I see differing variable declarations like the following; %var%, %var, !var! ect...