标题: 请问 :如何得到 当前 目录名 呢?(已结)
[打印本页]
作者: huzixuan
时间: 2007-3-15 04:08
标题: 请问 :如何得到 当前 目录名 呢?(已结)
如 当前目录是:
C:\Documents and Settings\Administrator\桌面\test
双击批处理需要得到 test
如:C:\Documents and Settings\Administrator\桌面\test1
双击批处理需要得到 test1
请大家 积极 踊跃 的回答;)
感谢 各位 ;) (这里 不欢迎 "日本人"!呵呵)
[
Last edited by huzixuan on 2007-3-15 at 06:57 AM ]
作者: fengzi
时间: 2007-3-15 04:10
哟西
[
Last edited by fengzi on 2007-3-14 at 03:11 PM ]
作者: ccwan
时间: 2007-3-15 05:35
@echo off
for /f "tokens=5 delims=\" %%i in ('cd') do echo %%i
pause
[
Last edited by ccwan on 2007-3-15 at 07:27 AM ]
作者: zh159
时间: 2007-3-15 05:37
@echo off
call :str "%cd%"
pause
exit
:str
echo %~n1
goto :eof
[
Last edited by zh159 on 2007-3-14 at 04:38 PM ]
作者: huzixuan
时间: 2007-3-15 07:00
zh159 兄
你的 call 用的好巧妙!
作者: jmz573515
时间: 2007-3-15 08:26
谢谢7楼的纠正,已经修改请测试...
@echo off
for /f "delims=" %%i in ("%cd%") do (
if %%i EQU %%~di\ (
echo %%~di
) else (
echo %%~ni
)
)
pause>nul
[
Last edited by jmz573515 on 2007-3-14 at 10:23 PM ]
作者: xycoordinate
时间: 2007-3-15 10:48
Quote: |
Originally posted by zh159 at 2007-3-14 16:37:
@echo off
call :str "%cd%"
pause
exit
:str
echo %~n1
goto :eof [ Last edited by zh159 on 2007-3-14 at 04:38 PM ] |
|
测试:
Quote: |
F:\zdrq>test
zdrq
请按任意键继续. . .
ECHO 处于关闭状态。
还有它和第6楼的,如果在X:\根目录下,都不行!
ECHO 处于打开状态。 |
|
[
Last edited by xycoordinate on 2007-3-15 at 08:19 AM ]