DOS BAT file equivalent to Unix basename command?

前端 未结 8 1356
野趣味
野趣味 2020-12-03 00:43

Is there an easy way to get to the basename (file name without extension) of a DOS file name using the DOS BAT command language?

I agree: format c:\\ is

8条回答
  •  清歌不尽
    2020-12-03 01:13

    Full-working solution (even when path contains spaces)

    in .bat files

    for /F "delims=" %%i in (%FILE_path%) do @echo "%%~ni"
    

    in command-prompt use % instead of %%

    (thanks to @Ciantic)

提交回复
热议问题