【发布时间】:2015-05-29 03:18:26
【问题描述】:
特别是在 Windows 7 的批处理文件中,可以使用该行
设置 MYDIR=%~dps0%
获取包含批处理文件的目录路径。
在 Windows 7 机器上,它包含为路径元素生成的 8.3 名称。
有没有办法获得这个路径的“长文件名”版本?从“.bat”文件中??
【问题讨论】:
标签: windows batch-file
特别是在 Windows 7 的批处理文件中,可以使用该行
设置 MYDIR=%~dps0%
获取包含批处理文件的目录路径。
在 Windows 7 机器上,它包含为路径元素生成的 8.3 名称。
有没有办法获得这个路径的“长文件名”版本?从“.bat”文件中??
【问题讨论】:
标签: windows batch-file
只需摆脱s。
set MYDIR=%~dp0
来自for /?:
%~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
【讨论】: