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

最新文章

  1. 利用 img 和 script 发送跨域请求
  2. 分布式文件系统FastDFS安装与配置(单机)
  3. [转] What is the point of redux when using react?
  4. CentOS6.6修改主机名和网络信息
  5. linux下find命令-atime,-ctime,-mtime真正含义
  6. oracle scn浅析
  7. HTML——UL+CSS设计
  8. PHP函数 mysql_real_escape_string 与 addslashes 的区别
  9. 模式识别与机器学习—bagging与boosting
  10. ubuntu中设置php7.0-fpm开机自启动
  11. leetcode之旅(8)-Contains Duplicate
  12. python之动态参数 *args,**kwargs和命名空间
  13. Flutter之Container详解
  14. 文件编码检测.ZC一些资料(包含java的)
  15. Ceph常规操作及常见问题梳理
  16. JavaScript学习 - 基础(七) - DOM event(事件)
  17. VS IIS Express 支持局域网访问
  18. Hadoop概念学习系列之Hadoop新手学习指导之入门需知(二十)
  19. VHDL基础2
  20. 《Forward团队-爬虫豆瓣top250项目-开发文档》

热门文章

  1. shell变量替换扩展 变量测试
  2. 在Kubernetes下部署Prometheus
  3. lombok 注解简单介绍
  4. leetcode-161周赛-5248-统计【优美子数组】
  5. java中文件下载的思路(参考:孤傲苍狼)
  6. Http请求工具类 httputil
  7. jmeter登录之-动态参数
  8. (转)短信vs.推送通知vs.电子邮件:app什么时候该用哪种方式来通知用户?
  9. ios移动输入框被软键盘遮挡
  10. Ubuntu下安装Samba服务器