forfiles 命令详解

C:\Users\cuixunxu>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

Batch - forfiles 命令详解的更多相关文章

  1. forfiles命令详解

    目录复制命令: xcopy   //server/bak/*.*    d:/serverbak /s /e /v /c / d /y /h             at 05:30 shutdown ...

  2. Spring Batch(4): Job详解

    Spring Batch(4): Job详解 2016-03-26 18:46 870人阅读 评论(1) 收藏 举报  分类: Spring(6)  版权声明:本文为博主原创文章,未经博主允许不得转载 ...

  3. Dockerfile 命令详解及最佳实践

    Dockerfile 命令详解 FROM 指定基础镜像(必选) 所谓定制镜像,那一定是以一个镜像为基础,在其上进行定制.就像我们之前运行了一个 nginx 镜像的容器,再进行修改一样,基础镜像是必须指 ...

  4. Git初探--笔记整理和Git命令详解

    几个重要的概念 首先先明确几个概念: WorkPlace : 工作区 Index: 暂存区 Repository: 本地仓库/版本库 Remote: 远程仓库 当在Remote(如Github)上面c ...

  5. linux yum命令详解

    yum(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及SUSE中的Shell前端软件包管理器.基於RPM包管理,能够从指定的服务器自动下载RP ...

  6. Linux下ps命令详解 Linux下ps命令的详细使用方法

    http://www.jb51.net/LINUXjishu/56578.html Linux下的ps命令比较常用 Linux下ps命令详解Linux上进程有5种状态:1. 运行(正在运行或在运行队列 ...

  7. Docker命令详解

    Docker命令详解   最近学习Docker,将docker所有命令实验了一番,特整理如下: # docker --help Usage: docker [OPTIONS] COMMAND [arg ...

  8. linux awk命令详解

    linux awk命令详解 简介 awk是一个强大的文本分析工具,相对于grep的查找,sed的编辑,awk在其对数据分析并生成报告时,显得尤为强大.简单来说awk就是把文件逐行的读入,以空格为默认分 ...

  9. android adb 命令详解

    ADB (Android Debug Bridge)  是android SDK中的工具,需要先配置环境变量才能使用.起调试桥的作用,可以管理安卓设备.(也叫debug工具) ---------查看设 ...

随机推荐

  1. zookeeper常用配置详解

    #ZK中的一个时间单元.ZK中所有时间都是以这个时间单元为基础,进行整数倍配置的.例如,session的最小超时时间是2*tickTime tickTime=2000 #Follower在启动过程中, ...

  2. Stm32CubeMX5 配置使用ADC

    试验,通过ADC按键 按下时的不同电压,然后把相应的数字量通过串口发出, 1. 使用 ADC 检测按键, 原理图分析 2. Stm32CubeMX5配置 ADC功能,先配置PA0为ADC模式 配置 A ...

  3. JAVA基础学习-多态 对象转型 final

    一.多态的产生条件 1:继承  存在继承的类之间 2:方法重装 3:父类继承子类重装的方法 子类的对象 也是属于父类的 二:对象的转型 1:向上转型:当子类转型成父类时 例如:Animal a = n ...

  4. case ...esac判断 function方法 循环loop,while do done,until do done

    就类似于其他语言中的case语句 用法 要点 第一 开始结束  case  esac 正好相反 第二  每段程序段需要用  两个:号结束. 例: } in "hello") ech ...

  5. 使用Turbine对集群进行监控

    为什么要使用Turbine Turbine是聚合服务器发送事件流数据的一个工具,hystrix的监控中,只能监控单个节点,实际生产中都为集群,因此可以通过turbine来监控集群下hystrix的me ...

  6. windows API 第22篇 WTSGetActiveConsoleSessionId

    函数原型:DWORD WTSGetActiveConsoleSessionId (VOID)先看一下原文介绍: The WTSGetActiveConsoleSessionId function re ...

  7. STL_set

    #include <iostream> #include <set> #include <string> #include <cstdio> using ...

  8. web.xml中配置——解决post乱码

    <!-- 解决post乱码 --> <filter> <filter-name>CharacterEncodingFilter</filter-name> ...

  9. Java中基本类型的包装类

    基本类型包装类: 项目中我们常常放弃基本类型,用基本类型的包装类 基本类型包装类有哪些: Int--Integer char--Character double--Double 以Intger为例讲述 ...

  10. 分块——cf1207F

    这么傻逼的题当时想了那么久 用a数组维护原序列,b[i][j]表示 pos%i=j 的 a[pos]之和 对于每个修改1 x y,先直接修改a[x],然后枚举i=1..700,修改b[i][x%i] ...