给定存储在变量中的绝对路径:
SET absolute_file_path=C:\path\containing\some.json
使用命令提示符,如何从C:\path\containing\
中提取绝对目录路径C:\path\containing
或%absolute_file_path%
?
答案 0 :(得分:2)
for
有一些修饰符可以获取路径\ filename的部分内容:
SET absolute_file_path=C:\path\containing\some.json
for %%A in (%absolute_file_path%) do (
echo file name: %%~nA
echo file extension: %%~xA
echo full file name: %%~nxA
echo drive: %%~dA
echo path: %%~pA
echo drive/path: %%~dpA
echo full qualified filename: %%~fA
)
call
ed子例程具有相同的修饰符。请参阅for /?
和call /?
答案 1 :(得分:0)
@echo off
SET absolute_file_path=C:\path\containing\some.json
setlocal enabledelayedexpansion
set I=0
set L=-1
:l
if "!absolute_file_path:~%I%,1!"=="" goto ld
if "!absolute_file_path:~%I%,1!"=="\" set L=%I%
set /a I+=1
goto l
:ld
echo %L%
CALL SET ab_path=%%absolute_file_path:~0,%L%%%
echo %ab_path%
答案 2 :(得分:0)
这实际上回答了你的问题:
let messageDB = Database.database().reference().child("Message")
let messageQuery = messageDb.queryOrdered(byChild:"fromID").queryEqual(toValue: (Auth.auth().currentUser?.uid)!)
messageQuery.observe(.childAdded) { (snapshot) in