中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-10 16:54
47,811 topics / 349,897 posts / today 0 new / 48,256 members
DOS批处理 & 脚本技术(批处理室) » [Help] How to get the current path
Printable Version  4,506 / 10
Floor1 nre Posted 2004-07-21 00:00
银牌会员 Posts 361 Credits 1,210
For example, I am in the c:\temp directory. How can I assign this path to a variable? Does anyone have a small program or a good method? Thanks
Floor2 Climbing Posted 2004-07-21 00:00
铂金会员 Posts 2,753 Credits 6,962 From 河北保定
You need to use Horst's lmod as follows:
cd | lmod /L1 set curdir= > temp.bat
call temp.bat
del temp.bat
After execution, the current directory will be saved to the curdir environment variable.
Floor3 nre Posted 2004-07-21 00:00
银牌会员 Posts 361 Credits 1,210
Where can I find the lmod small program?
Floor4 Climbing Posted 2004-07-21 00:00
铂金会员 Posts 2,753 Credits 6,962 From 河北保定
Floor5 JonePeng Posted 2004-07-26 00:00
金牌会员 Posts 1,883 Credits 4,562 From 广东广州
No need to be so complicated! The %CD% variable is just the variable for the current path. If you don't believe it, you can try echo %cd% and see.
Floor6 Climbing Posted 2004-07-26 00:00
铂金会员 Posts 2,753 Credits 6,962 From 河北保定
The following is the statement made by JonePeng on 2004-7-26 22:56:12:

No need to be so complicated!
The %CD% variable is the variable for the current path. If you don't believe it, you can try echo %cd% to see.

Please try to type echo %cd% under 98!
Floor7 BAT Posted 2006-07-17 04:36
初级用户 Posts 52 Credits 177
I want to ask, besides third - party tools, is there any other solution?
Floor8 chenall Posted 2006-07-17 08:10
银牌会员 Posts 469 Credits 1,276 From 福建泉州
Search the forum.
Floor9 w1314ich Posted 2007-12-04 18:33
中级用户 Posts 119 Credits 234
echo %cd% is quite useful~~ If it only doesn't work under 98, then it's okay. Now there are few people using 98 systems. Some things are still simpler, don't seem too professional
Floor10 jethroso Posted 2010-03-16 21:55
新手上路 Posts 4 Credits 4
`%cd%` in folders with spaces, such as the desktop, doesn't seem to work
Floor11 jarry0932 Posted 2010-03-16 23:34
初级用户 Posts 122 Credits 128
The desktop can be achieved with "%cd%".
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023