How can I set a variable with the current location? For instance, if I get in c:\test
and want to set the variable to test
and if I get inside c:\test\test2
the variable will be set to test2
.
I'm thinking about using a for
to get inside a lot of folders and check if some file exists, if the correct file exist I want to set the current folder to a variable so I can copy the path and copy the folder.
The main problem deals with copying the rest of the files is the same folder as the .inf file.
When creating batch files, you can use set to create variables, and then use them in the same way that you would use the numbered variables %0 through %9. You can also use the variables %0 through %9 as input for set. If you call a variable value from a batch file, enclose the value with percent signs (%).
%%i is simply the loop variable. This is explained in the documentation for the for command, which you can get by typing for /? at the command prompt.
It is the directory from where you start the batch file. E.g. if your batch is in c:\dir1\dir2 and you do cd c:\dir3 , then run the batch, the current directory will be c:\dir3 .
The current directory is in the "shadow" variable cd.
You could try
set "var=%cd%"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With