HOME

TheInfoList



OR:

forfiles is a computer software
utility As a topic of economics, utility is used to model worth or value. Its usage has evolved significantly over time. The term was introduced initially as a measure of pleasure or happiness as part of the theory of utilitarianism by moral philosoph ...
for Microsoft Windows, which selects files and runs a
command Command may refer to: Computing * Command (computing), a statement in a computer language * COMMAND.COM, the default operating system shell and command-line interpreter for DOS * Command key, a modifier key on Apple Macintosh computer keyboards ...
on them. File selection criteria include name and last modified date. The command specifier supports some special syntax options. It can be used directly on the
command-line A command-line interpreter or command-line processor uses a command-line interface (CLI) to receive command (computing), commands from a user in the form of lines of text. This provides a means of setting parameters for the environment, invokin ...
, or in
batch file Batch may refer to: Food and drink * Batch (alcohol), an alcoholic fruit beverage * Batch loaf, a type of bread popular in Ireland * A dialect term for a bread roll used in North Warwickshire, Nuneaton and Coventry, as well as on the Wirra ...
s or other
scripts Script may refer to: Writing systems * Script, a distinctive writing system, based on a repertoire of specific elements or symbols, or that repertoire * Script (styles of handwriting) ** Script typeface, a typeface with characteristics of ha ...
. The forfiles command was originally provided as an add-on, in the
Windows 98 Windows 98 is a consumer-oriented operating system developed by Microsoft as part of its Windows 9x family of Microsoft Windows operating systems. The second operating system in the 9x line, it is the successor to Windows 95, and was released ...
,
Windows NT Windows NT is a proprietary graphical operating system produced by Microsoft, the first version of which was released on July 27, 1993. It is a processor-independent, multiprocessing and multi-user operating system. The first version of Wi ...
and
Windows 2000 Windows 2000 is a major release of the Windows NT operating system developed by Microsoft and oriented towards businesses. It was the direct successor to Windows NT 4.0, and was released to manufacturing on December 15, 1999, and was official ...
Forfiles.exe - Windows 2000 Resource Kit Utility
/ref>
Resource Kit Resource Kit is a term used by Microsoft for a set of software resources and documentation released for their software products, but which is not part of that product. Resource kits offer supplementary resources such as technical guidance, compatib ...
s. It became a standard utility with
Windows Vista Windows Vista is a major release of the Windows NT operating system developed by Microsoft. It was the direct successor to Windows XP, which was released five years before, at the time being the longest time span between successive releases of ...
, as part of the new management features.


Usage

The forfiles command has several command-line switches. If no switches or parameters given, it outputs the name of every file in the
current directory In computing, the working directory of a process is a directory of a hierarchical file system, if any, dynamically associated with each process. It is sometimes called the current working directory (CWD), e.g. the BSD getcwd function, or just cur ...
.


Switches


Command syntax

The command string is executed as given, except as noted below. Sequences of the form , where "0x" is literal, and "FF" represents any two-digit
hexadecimal In mathematics and computing, the hexadecimal (also base-16 or simply hex) numeral system is a positional numeral system that represents numbers using a radix (base) of 16. Unlike the decimal system representing numbers using 10 symbols, h ...
number, are replaced with the corresponding single-byte value. This can be used to embed non-printing
ASCII ASCII ( ), abbreviated from American Standard Code for Information Interchange, is a character encoding standard for electronic communication. ASCII codes represent text in computers, telecommunications equipment, and other devices. Because ...
characters, or
extended ASCII Extended ASCII is a repertoire of character encodings that include (most of) the original 96 ASCII character set, plus up to 128 additional characters. There is no formal definition of "extended ASCII", and even use of the term is sometimes critic ...
characters. The sequence is replaced with a literal quotation mark . Using the 0x sequence form described previously, can also be used, which additionally hides the from the command interpreter. Several variables are provided, to be used in the command as placeholders for the values from each file. Variables are technically not required, but must be used if the command is to vary for each file.


Date syntax

The date switch (/D) selects files based on their last modified date, given a ''date'' argument. The date argument can be given as a literal date, in MM/DD/YYYY format (other date formats are not accepted). Alternatively, the date argument can be given as a number, in which case it is taken to mean an age in days (i.e., the day ''date'' days before the present date). If the ''date'' argument begins with a minus (-), only files modified on or before the given date are selected (older file / modified earlier). Otherwise, only files modified on or after the given date are selected (younger files / modified later). An explicit plus (+) may be given, but is the default. Note that both modes select files on the given date. There is no way to select files only on a given date (without also either before or after).


Examples

The following command selects all log files (*.LOG) in the Windows directory 30 days or older, and lists them with their date. C:\>FORFILES /P C:\Windows /M *.LOG /D -30 /C "CMD /C ECHO @FDATE @FILE" 6/12/2015 "iis7.log" 5/28/2015 "msxml4-KB954430-enu.LOG" 5/28/2015 "msxml4-KB973688-enu.LOG" 5/26/2015 "setuperr.log" The following command would delete the same files. C:\>FORFILES /P C:\Windows /M *.LOG /D -30 /C "CMD /C DEL @PATH" The use of is required in the above examples, as both and are internal to the
command processor A command-line interpreter or command-line processor uses a command-line interface (CLI) to receive commands from a user in the form of lines of text. This provides a means of setting parameters for the environment, invoking executables and pro ...
, rather than external utility programs.


See also

* cmd.exe – The program implementing the Windows command-line interpreter *
Foreach loop In computer programming, foreach loop (or for each loop) is a control flow statement for traversing items in a collection. is usually used in place of a standard loop statement. Unlike other loop constructs, however, loops usually maintai ...
– The FOR and FORFILES commands both implement a ''for-each loop'' *
find (Unix) In Unix-like and some other operating systems, find is a command-line utility that locates files based on some user-specified criteria and either prints the pathname of each matched object or, if another action is requested, performs that acti ...
– Unix command that finds files by attribute, similar to forfiles *
find (Windows) In computing, find is a command in the command-line interpreters ( shells) of a number of operating systems. It is used to search for a specific text string in a file or files. The command sends the specified lines to the standard output devi ...
– DOS and Windows command that finds text matching a pattern *
grep grep is a command-line utility for searching plain-text data sets for lines that match a regular expression. Its name comes from the ed command ''g/re/p'' (''globally search for a regular expression and print matching lines''), which has the sa ...
– Unix command that finds text matching a pattern, similar to Windows find


References

* . * *


External links


forfiles , Microsoft Docs
{{Windows commands Windows Vista Utility software Command-line software Windows administration