bat 获取当前文件夹路径

bat 获取当前文件夹路径

1, 当前文件夹的路径 有两种方法

"%~dp0"  and "%cd%" ,区别在于cd输出没有最后“\”

2, Set 后面字符串不能有空格,如 file = ...

3, 加上引号防止路径中有空格

cur_dir = "%~dp0"
cur_dir2 = "%cd%"
echo %cur_dir
echo %cur_dir2%
Set file="%~dp0%""new.py"
Set file=%file:"=%
echo "%file%"
python %file% hello
pause>nul

posted @ 2013-06-28 13:57  xurui  阅读(1578)  评论(0编辑  收藏  举报