I have a reasonably simple question, however i cannot seem to find a solution anywhere.
I'm working with some variables in a batch file, and i would like to change the directory according to the variable.
eg,
variable SET /Jan2000 = a
cd P:\Reference\Data\2000\%a%
When i run the batch file, it just stays in the "2000" folder, it does not go the folder below like i ask. Is there any way to get this to work?
Edit: by request, here is the exact code as it is writtenin the batch file. Thanks for the help.
chdir /D P:\Reference\Data\2000
SET Jan2000 = a
chdir P:\Reference\2000\%a%
dir
pause
You need to SET
your variable.
For example:
SET a=Jan2000
CD P:\Reference\Data\2000\%a%
I can't add much to @aphoria's answer but try this
set a=jan2000
pushd P:\Reference\Data\2000\%a%
Using pushd
instead of cd
incase there's a problem with changing directory over drives. (I know, the /d
switch is for that, but worth a shot).
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