zoukankan      html  css  js  c++  java
  • Batch

    forfiles 命令详解

    C:Userscuixunxu>forfiles /?
    
    FORFILES [/P pathname] [/M searchmask] [/S]
             [/C command] [/D [+ | -] {MM/dd/yyyy | dd}]
    
    Description:
        Selects a file (or set of files) and executes a
        command on that file. This is helpful for batch jobs.
    
    Parameter List:
        /P    pathname      Indicates the path to start searching.
                            The default folder is the current working
                            directory (.).表示开始搜索的路径。默认文件夹是当前工作的目录 (.)
    
        /M    searchmask    Searches files according to a searchmask.
                            The default searchmask is '*' .根据搜索掩码搜索文件。默认搜索掩码是 '*'
    
        /S                  Instructs forfiles to recurse into
                            subdirectories. Like "DIR /S".指导 forfiles 递归到子目录。像 "DIR /S"。
    
        /C    command       Indicates the command to execute for each file.
                            Command strings should be wrapped in double
                            quotes. 表示为每个文件执行的命令。命令字符串应该用双引号括起来。
    
                            The default command is "cmd /c echo @file". 默认的command是“cmd /c echo @file”
    
                            The following variables can be used in the
                            command string:
                            @file    - returns the name of the file.返回文件名
                            @fname   - returns the file name without
                                       extension.返回不带扩展名的文件名
                            @ext     - returns only the extension of the
                                       file.只返回文件的扩展
                            @path    - returns the full path of the file.返回文件的完整路径
                            @relpath - returns the relative path of the
                                       file.返回文件的相对路径
                            @isdir   - returns "TRUE" if a file type is 如果文件类型是目录,返回true 
                                       a directory, and "FALSE" for files.如果是文件,返回false
                            @fsize   - returns the size of the file in
                                       bytes.以字节为单位返回文件大小
                            @fdate   - returns the last modified date of the
                                       file.返回文件上一次修改的日期
                            @ftime   - returns the last modified time of the
                                       file.返回文件上一次修改的时间
    
                            To include special characters in the command
                            line, use the hexadecimal code for the character
                            in 0xHH format (ex. 0x09 for tab). Internal
                            CMD.exe commands should be preceded with
                            "cmd /c".
    
        /D    date          Selects files with a last modified date greater
                            than or equal to (+), or less than or equal to
                            (-), the specified date using the
                            "MM/dd/yyyy" format; or selects files with a
                            last modified date greater than or equal to (+)
                            the current date plus "dd" days, or less than or
                            equal to (-) the current date minus "dd" days. A
                            valid "dd" number of days can be any number in
                            the range of 0 - 32768.
                            "+" is taken as default sign if not specified. 指定日期,有绝对日期和相对日期, 此处-7指当前日期 的7天前
    
        /?                  Displays this help message.显示此帮助消息
    
    Examples:
        FORFILES /?
        FORFILES
        FORFILES /P C:WINDOWS /S /M DNS*.*
        FORFILES /S /M *.txt /C "cmd /c type @file | more"
        FORFILES /P C: /S /M *.bat
        FORFILES /D -30 /M *.exe
                 /C "cmd /c echo @path 0x09 was changed 30 days ago"
        FORFILES /D 01/01/2001
                 /C "cmd /c echo @fname is new since Jan 1st 2001"
        FORFILES /D +9/27/2019 /C "cmd /c echo @fname is new today"
        FORFILES /M *.exe /D +1
        FORFILES /S /M *.doc /C "cmd /c echo @fsize"
        FORFILES /M *.txt /C "cmd /c if @isdir==FALSE notepad.exe @file"

    注意:

    这些命令是等价的: /S 等同于 -s, /M 等同于 -m

  • 相关阅读:
    .net WebApi中使用swagger
    HTTP Error 503. The service is unavailable
    python3消费rocketmq
    docker安装部署showdoc
    EasyMock.replay()有什么用
    java.lang.IllegalStateException: 1 matchers expected, 5 recorded.
    io.spring.platform继承方式和import方式更改依赖版本号的问题
    spring-boot-dependencies、spring-boot-starter-parent、io.spring.platform详解
    springboot依赖的一些配置:spring-boot-dependencies、spring-boot-starter-parent、io.spring.platform
    一个最简单的springboot
  • 原文地址:https://www.cnblogs.com/frankcui/p/11599284.html
Copyright © 2011-2022 走看看