Get filename from string-path?

安稳与你 提交于 2019-11-30 04:31:52

Method 1

for %%F in ("C:\Documents and Settings\Usuario\Escritorio\hello\test.txt") do echo %%~nxF

Type HELP FOR for more info.

Method 2

call :sub "C:\Documents and Settings\Usuario\Escritorio\hello\test.txt"
exit /b

:sub
echo %~nx1
exit /b

Type HELP CALL for more info.

if your path comes as a parameter, just use:

%~nx1 (1 is for the first param and we suppose it's the first one)

echo %~nx1 would return directly test.txt

Assuming you need the the names of files under the "c:\temp" directory tree (including sub-directories):

FOR /R c:\temp %i in (*.*) do echo %~nxi
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!