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

  • 相关阅读:
    求二叉树的层次遍历
    求二叉树的先序遍历
    数据结构实验之二叉树一:树的同构
    list列表操作
    汉罗塔问题
    expected an indented block
    42步进阶学习—让你成为优秀的Java大数据科学家!
    MVC 3.0错误 HTTP 404您正在查找的资源(或者它的一个依赖项)可能已被移除,或其名称已更改,或暂时不可用。请检查以下 URL 并确保其拼写正确。
    判断浏览器版本
    VisualStudio2012编辑器错误
  • 原文地址:https://www.cnblogs.com/frankcui/p/11599284.html
Copyright © 2011-2022 走看看