aja*_*221 28 string filenames batch-file
如何从此字符串中获取文件名?
"C:\Documents and Settings\Usuario\Escritorio\hello\test.txt"
Run Code Online (Sandbox Code Playgroud)
输出:
"test.txt"
Run Code Online (Sandbox Code Playgroud)
我真的试图在发布之前找到这个,但所有结果都被污染了,他们谈论从当前目录获取文件名(我必须只使用字符串)
dbe*_*ham 59
方法1
for %%F in ("C:\Documents and Settings\Usuario\Escritorio\hello\test.txt") do echo %%~nxF
Run Code Online (Sandbox Code Playgroud)
键入HELP FOR更多信息.
方法2
call :sub "C:\Documents and Settings\Usuario\Escritorio\hello\test.txt"
exit /b
:sub
echo %~nx1
exit /b
Run Code Online (Sandbox Code Playgroud)
键入HELP CALL更多信息.
假设您需要"c:\ temp"目录树(包括子目录)下的文件名:
FOR /R c:\temp %i in (*.*) do echo %~nxi
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
52621 次 |
| 最近记录: |