zoukankan      html  css  js  c++  java
  • FORFILES

    Select a file (or set of files) and execute a command on each file. Batch processing.

    Syntax
          FORFILES [/p Path] [/m Mask] [/s] [/c Command] [/d[+ | -] {dd/MM/yyyy | dd}]   
    
    Key
       /p Path      The Path to search  (default=current folder)
    
       /s           Recurse into sub-folders
    
       /C command   The command to execute for each file.
                    Wrap the command string in double quotes.
                    Default = "cmd /c echo @file"
    
                    The Command variables listed below can also be used in the
                    command string.
    
       /D date      Select files with a last modified date greater than or 
                    equal to (+), or less than or equal to (-),
                    the specified date using the "dd/MM/yyyy" format;
    
       /D + dd      Select files with a last modified date greater than or
                    equal to the current date plus "dd" days. (in the future)
    
       /D - dd      Select files with a last modified date less than or
                    equal to the current date minus "dd" days. (in the past)
    
                    A valid "dd" number of days can be any number in
                    the range of 0 to 32768.   (89 years)
                    "+" is taken as default sign if not specified.
    
       Command Variables:
          @file    The name of the file.
          @fname   The file name without extension.                
          @ext     Only the extension of the file.                  
          @path    Full path of the file.
          @relpath Relative path of the file.          
          @isdir   Returns "TRUE" if a file type is a directory,
                   and "FALSE" for files.
          @fsize   Size of the file in bytes.
          @fdate   Last modified date of the file.
          @ftime   Last modified time of the file.

    To include special characters in the command line, use the hex code for the character in 0xHH format (ex. 0x09 is theTAB character, 0x22 is the double quote " character.) so "C:\Program Files\" becomes ^0x22C:\Program^ Files\^0x22

    Internal CMD.exe commands must be preceded with "cmd /c".

    If ForFiles finds one or more matches if will return %errorlevel% =0
    If ForFiles finds no matches if will return %errorlevel% =1 and will print "ERROR: No files found with the specified search criteria."

    The old NT4 version of ForFiles used unix style -parameters, and could only match dates newer than a specified date using the following command variables names: (which must be upper case) @FILE, @FNAME_WITHOUT_EXT, @EXT, @PATH, @RELPATH, @ISDIR, @FSIZE, @FDATE, @FTIME
    The Windows 2000 version of ForFiles also used unix-style parameters but is otherwise the same as current versions.

    Last modified dates set in the future are not common but can happen when your computer clock date/time is changed e.g. due to daylight savings time.

    Examples:

    Delete the testfile if it is is 5 days old or older:
    C:\> forfiles /m testfile.txt /c "cmd /c Del testfile.txt " /d -5

    Find .xls file that were last modified 30 days ago or older
    C:\> FORFILES /M *.xls /C "cmd /c echo @path was changed 30 days ago" /D -30

    List the size of all .doc files:
    C:\> FORFILES /S /M *.doc /C "cmd /c echo @fsize"

    An alternative method of dealing with files older or newer than a specified date is to use ROBOCOPY

    Rule #1: Don’t sweat the small stuff.
    Rule #2: It's all small stuff - Dr Robert S Eliot, University of Nebraska cardiologist


    Related:

    Syntax - Delete files older than N days
    FOR - Conditionally perform a command several times.
    Powershell: ForEach-Object - Loop for each object in the pipeline
    Equivalent bash command (Linux): find - Search for files that meet a desired criteria

  • 相关阅读:
    spring多个context:property-placeholder不生效问题
    JAVA中自定义properties文件介绍
    spring.jar是包含有完整发布的单个jar 包,spring.jar中包含除了spring-mock.jar里所包含的内容外其它所有jar包的内容,因为只有在开发环境下才会用到 spring-mock.jar来进行辅助测试,正式应用系统中是用不得这些类的。
    web.xml文件头声明各个版本参考
    Java 组件化(gradle)
    阿里开源框架-JarsLink-【JAVA的模块化开发框架】
    二gradle创建SSM项目——Hello word
    一gradle创建SSM项目——依赖包
    微信开发学习总结(二)——微信开发入门
    js函数声明的三种方式
  • 原文地址:https://www.cnblogs.com/flysun0311/p/2759925.html
Copyright © 2011-2022 走看看