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. python 正则匹配

    正则表达式模式 模式字符串使用特殊的语法来表示一个正则表达式: 字母和数字表示他们自身.一个正则表达式模式中的字母和数字匹配同样的字符串. 多数字母和数字前加一个反斜杠时会拥有不同的含义. 标点符号只 ...

  2. 头文件 <sys/un.h>

    struct sockaddr_un server_sockaddr ; struct sockaddr_un cli_sockaddr ;

  3. js实现点击按钮控制展开与收起.

    html <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <ti ...

  4. Python文件路径操作

    print(os.environ.get('HOME')) # 打印`HOME`这个环境变量 /Users/<> file_path = os.environ.get('HOME') + ...

  5. js实现复制|剪切指定内容到粘贴板--clipboard

    这是著名开源项目 clipboard.js 的 README.md,里面讲解的更加详细,有兴趣的同学可以了解一下.项目地址:https://github.com/zenorocha/clipboard ...

  6. vue-cli 3.0版本,配置代理Proxy,不同环境不同target(生产环境,uat环境和本地环境的配置)

    1.在项目的的根目录下新建vue.config.js 2.新建一个config包,里面存放不同的环境文件,里面包含:pro.env.js(生产环境配置),uat.env.js(测试环境配置),dev. ...

  7. Delphi 打印纸张选项设置参数

    { paper selections } {$EXTERNALSYM DMPAPER_LETTER} DMPAPER_LETTER = 1; { Letter 8 12 x 11 in } {$EXT ...

  8. CSP-S考前各种idea题解乱堆

    快要考试了我还是这么菜. 已经没有心思维护我的博客了.开一篇博文吧.可能会记得很乱. 这也许是我OI生涯的最后一篇博文了?? 肯定很长很长. 不可能的.谁知道什么时候我心态恢复就把上面两句话删掉开始在 ...

  9. Python 生成json文件

    1.数据准备 数据下载 2.python代码 import datetime import os import mssqlhelper ms = mssqlhelper.MSSQL(host=&quo ...

  10. NX二次开发-BlockUI对话框嵌套MFC对话框制作进度条

    半年前在一些QQ群看到有大神NX二次开发做出了进度条,那个时候我还不会弄,也不知道怎么弄得,后来断断续续得研究了一下,直到今天我把它做出来了.内心还是很喜悦的!回想自己这两年当初从没公司肯给我做NX二 ...