Get parent directory name for a particular file using DOS Batch scripting

后端 未结 9 1304
無奈伤痛
無奈伤痛 2020-12-08 21:33

I need to find the name of the parent directory for a file in DOS

for ex.

Suppose this is the directory

C:\\test\\pack\\a.txt
9条回答
  •  北荒
    北荒 (楼主)
    2020-12-08 22:34

    call :set_dirname "%cd%"
    echo %DIRNAME%
    
    
    :set_dirname
    set DIRNAME=%~n1
    goto :eof
    

提交回复
热议问题