In this article, Forfiles and its impact on today's society will be analyzed in detail. From its origins to its evolution and relevance in different areas, Forfiles has played a fundamental role in people's lives. Through this article, its multiple facets will be explored and its influence will be examined in various contexts, from the personal to the global level. It will examine how Forfiles has shaped the way we interact, communicate and experience the world around us. In addition, possible future scenarios and their meaning for humanity in general will also be considered.
The directory in which to search instead of the working directory. UNC paths (\\machine\share) are not accepted.
/M pattern
Specifies a wildcard matching pattern that selects items for inclusion instead of all items. It results in filtering out items that do not match the pattern. It is matched on the item name (including extension) but not the containing directory path. Without a wildcard, the pattern must exactly match the base name.
Even though most DOS/Windows commands match files with no extension for the pattern *.*, this command treats *.* and * differently. The former only matches an item with a dot in its name, while the latter matches even with no dot or extension.
/S
Match items in subdirectories in addition to the specified directory.
/C command
Command to execute for each matching item. The command string typically must be wrapped in double quotes. The default command is CMD /C ECHO @FILE, which prints, via ECHO, the name of each matching item specified as variable @FILE. See below for supported variables.
A hexadecimal value with a "0x" prefix is treated as an ASCII character code which allows for the use of non-printing or extended ASCII characters. A double quote can be represented as either 0x22 or \".
/D date
Selects based on last modified date. By default, items are selected regardless of modified date.
A date argument is formatted as MM/DD/YYYY or as a number; an age in days (i.e., the day date days before the present date). If the argument begins with a minus (-), only items modified on or before the date are selected (older item / modified earlier). Otherwise, only items modified on or after the given date are selected (younger items / modified later). An explicit plus (+) may be given, but is the default. Note that both modes select items on the given date. There is no way to select items only on a given date (without also either before or after).
The following variables are replaced before the command is executed with metadata about the matched item.
@file
The name of the item, double quoted.
@fname
The name of the item without extension, double quoted.
@ext
The name extension, double quoted, without leading dot. If an item has multiple extensions, this evaluates to the last one. If the items has no extension, this evaluates to an empty string.
@path
Full path of the matching item, double quoted, including drive letter, and extension (if any).
@relpath
Path of the matching item, double quoted, and relative to the starting directory (given by /P). Each path begins with a dot and backslash (.\).
@isdir
Evaluates to the literal string TRUE if the matching item is a directory, or FALSE if not.
@fsize
Size of the matching item, in bytes. Directories report a size of zero.
@fdate
Date the item was last modified, in the localized date format of the current user.
@ftime
Time the item was last modified, in the localized time format of the current user.
Examples
The following command selects log files in the Windows directory 30 days or older, and lists them with their date. Since the command for option /C must be a program, spawning a sub-shell (cmd.exe) via CMD/C is required for shell builtin command ECHO.