I'm trying to translate a bash script into a .bat script. The specific line I'm tripping over is this:
X=`pwd`
What is the .bat equivalent?
I need to take the directory that the script is currently running in as a variable so I can use a generic relative path to find files in the directory. I'm running on Windows-XP in the command prompt.
%%a are special variables created by the for command to represent the current loop item or a token of a current line. for is probably about the most complicated and powerful part of batch files. If you need loop, then in most cases for has you covered.
%%a refers to the name of the variable your for loop will write to. Quoted from for /? : FOR %variable IN (set) DO command [command-parameters] %variable Specifies a single letter replaceable parameter. (set) Specifies a set of one or more files. Wildcards may be used.
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 (%).
The current directory is available in the pseudo-variable %cd%
. So:
set X=%cd%
stores it in a variable named X.
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