In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces how to use the forfiles command in cmd. It is very detailed and has a certain reference value. Friends who are interested must finish it!
FORFILES [/ P pathname] [/ M searchmask] [/ S]
[/ C command] [/ D [+ | -] {yyyy-MM-dd | dd}]
Description:
Select a file (or group of files) and on that file
Execute an order. This helps batch jobs.
Parameter list:
/ P pathname indicates the path to start the search. The default folder is currently working
Catalog (.).
/ M searchmask searches for files based on the search mask. The default search mask is'*'.
/ S instructs forfiles to recurse to a subdirectory. Like "DIR / S".
/ C command represents the commands executed for each file. The command string should
Enclose it in double quotation marks.
The default command is "cmd / c echo @ file". The following variables
Can be used in a command string:
@ file-returns the file name.
@ fname-returns a file name without an extension.
@ ext-returns only the extension of the file.
Path-returns the full path to the file.
Relpath-returns the relative path to the file.
@ isdir-returns "TRUE" if the file type is a directory
If it is a file, return "FALSE".
Fsize-returns the file size in bytes.
Fdate-returns the date the file was last modified.
Ftime-returns the time when the file was last modified.
To include special characters on the command line, use 0xHH
The form uses hexadecimal codes (for example, 0x09 is tab).
Internal CMD.exe commands should be preceded by "cmd / c".
/ D date Select a file whose last modified date is greater than or equal to (+)
Or less than or equal to the date specified in the "yyyy-MM-dd" format
Or select a file whose last modified date is greater than or equal to (+)
Current date plus "dd" days, or less than or equal to (-) current
Date minus "dd" days. Valid "dd" days can be
Any number in the range of 0-32768. If not specified
"+" is used as the default symbol.
/? Displays a help message.
For example:
FORFILES /?
FORFILES
FORFILES / PC:\ WINDOWS / S / M DNS*.*
FORFILES / S / M * .txt / C "cmd / c type @ file | more"
FORFILES / PC:\ / S / M * .bat
FORFILES / D-30 / M. exe
/ C "cmd / c echo @ path 0x09 was changed before 30."
FORFILES / D 2001-01-01
/ C "cmd / c echo @ fname was new on January 1st, 2001."
FORFILES / D + 2012-5-1 / 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"
Here are some examples
=
The following is the batch process for deleting files backed up N days ago. Note: under windows2003, such as XP, because there is no forfiles.exe, you did not test to copy 2003 of the files to the system32 directory of XP.
Delete files under the backup directory of disk C that were last modified 10 days ago
=
Forfiles / p "c:\ backup" / d-10 / c "cmd / c echo deleting @ file... & & del / f @ path"
=
The following is a batch process for copying files from a day ago to another location
To copy the files whose last modification date is greater than or equal to July 1, 2007 in the C root directory to the D disk root directory
=
Forfiles / p "c:\" / d "2007-7-1" / c "cmd / c copy @ path d:\"
Windows Server 2003 built-in command line files, suitable for XP and above systems
Example:
Forfiles / m * .bkf / d-28 / c "cmd / c del @ file / f"
Delete the 28-day extension bkf file under the current directory (based on the current system time)
Forfiles automatically deletes the file delete 7 days ago
2008-09-12 15:01
Try using forfiles.exe.
Forfiles / p "d:\ test" / s / m *. * / d-7 / c "cmd / c del @ path"
Make a batch file, bat file and forfiles.exe in the same directory, create a shortcut to bat file in startup.
The above is all the contents of the article "how to use forfiles commands in cmd". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.