【问题标题】:in windows 7 .bat file can one get the long filename from a short one在 Windows 7 .bat 文件中,可以从一个短文件中获取长文件名
【发布时间】:2015-05-29 03:18:26
【问题描述】:

特别是在 Windows 7 的批处理文件中,可以使用该行

设置 MYDIR=%~dps0%

获取包含批处理文件的目录路径。

在 Windows 7 机器上,它包含为路径元素生成的 8.3 名称。

有没有办法获得这个路径的“长文件名”版本?从“.bat”文件中??

【问题讨论】:

    标签: windows batch-file


    【解决方案1】:

    只需摆脱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
    

    【讨论】:

    • 当然他们缺少的是:“- 扩展路径包含完整的长文件名,当它们与短版本不同时”
    • 我会试着去掉 s 看看
    • 好的,我尝试去掉 Windows 7 框上的 s 并使用 %~dp0% 而不是 %~dps0% ,它仍然提供路径中超过 8.3 目录的简短版本。哦,我们多么喜欢窗户 :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多