zoukankan      html  css  js  c++  java
  • 如何解析批处理文件中的参数

    上周,同事问我写批处理文件的一个问题,他要做的事情主要是深度拷贝文件,涉及到目录和文件名解析的问题。当时他抱怨了半天,说不好用。可我发现, MS 其实已经做了这个工作了。例如:

    %~ 1      可以去掉参数两边的引号

    %~ d1     可以得到盘符

    等等

     

    这是文档中关于参数的参数表

     

    Modifier

    Description

    %~1

    Expands %1 and removes any surrounding quotation marks ("").

    %~f1

    Expands %1 to a fully qualified path name.

    %~d1

    Expands %1 to a drive letter.

    %~p1

    Expands %1 to a path.

    %~n1

    Expands %1 to a file name.

    %~x1

    Expands %1 to a file extension.

    %~s1

    Expanded path contains short names only.

    %~a1

    Expands %1 to file attributes.

    %~t1

    Expands %1 to date and time of file.

    %~z1

    Expands %1 to size of file.

     

     

    关于批处理文件详细的信息在微软网站:

    http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/batch.mspx?mfr=true

  • 相关阅读:
    Spring boot 启动图片
    Spring Cloud 从入门到入门
    理解错误的 Arrays.asList()
    git github 对代码的管理
    【POJ 2154】Color
    CodeForces
    CodeForces
    CodeForces
    CodeForces
    [数据结构]Hash Table(哈希表)
  • 原文地址:https://www.cnblogs.com/A1240/p/366284.html
Copyright © 2011-2022 走看看