如何在 'for' 批处理命令中只获取文件名而不获取文件扩展名
How to get only file name in 'for' batch command and not file extension
使用此代码将视频上传到 YouTube 时,裸露的标题末尾有文件扩展名(在本例中为 .mp4)
for %%f in (*.mp4) do python --file="%%f" --title="%%f"
使用for %%f in (*.csv) do echo "%%~nf"
要了解更多信息,请执行 for /?
..这是您希望看到的部分
In addition, substitution of FOR variable references has been enhanced.
You can now use the following optional syntax:
%~I - expands %I removing any surrounding quotes (")
%~fI - expands %I to a fully qualified path name
%~dI - expands %I to a drive letter only
%~pI - expands %I to a path only
%~nI - expands %I to a file name only
%~xI - expands %I to a file extension only
%~sI - expanded path contains short names only
%~aI - expands %I to file attributes of file
%~tI - expands %I to date/time of file
%~zI - expands %I to size of file
%~$PATH:I - searches the directories listed in the PATH
environment variable and expands %I to the
fully qualified name of the first one found.
If the environment variable name is not
defined or the file is not found by the
search, then this modifier expands to the
empty string
使用此代码将视频上传到 YouTube 时,裸露的标题末尾有文件扩展名(在本例中为 .mp4)
for %%f in (*.mp4) do python --file="%%f" --title="%%f"
使用for %%f in (*.csv) do echo "%%~nf"
要了解更多信息,请执行 for /?
..这是您希望看到的部分
In addition, substitution of FOR variable references has been enhanced.
You can now use the following optional syntax:
%~I - expands %I removing any surrounding quotes (")
%~fI - expands %I to a fully qualified path name
%~dI - expands %I to a drive letter only
%~pI - expands %I to a path only
%~nI - expands %I to a file name only
%~xI - expands %I to a file extension only
%~sI - expanded path contains short names only
%~aI - expands %I to file attributes of file
%~tI - expands %I to date/time of file
%~zI - expands %I to size of file
%~$PATH:I - searches the directories listed in the PATH
environment variable and expands %I to the
fully qualified name of the first one found.
If the environment variable name is not
defined or the file is not found by the
search, then this modifier expands to the
empty string