Forrest logo
back to the forfiles tool

forfiles:tldr:1af64

forfiles: Search for files in the current directory.
$ forfiles
try on your machine

The "forfiles" command is a command-line tool available in Windows operating systems. It allows you to search or perform actions on files within a specified directory based on various criteria.

The basic syntax of the "forfiles" command is as follows:

forfiles [/p <Path>] [/m <SearchMask>] [/s [/c "<Command>"] [/d [{+|-}][{<Date> | dd}]]

Here is a breakdown of the different parameters:

  • "/p ": Specifies the path (directory) where you want to perform the search or actions. If not specified, it will default to the current directory.
  • "/m ": Sets the file search mask or pattern. It allows you to specify a specific file name or pattern to search for.
  • "/s": Searches the specified directory and all its subdirectories recursively.
  • "/c """ or "/c ": Specifies the command that you want to execute for each file found. The "" placeholder can be replaced with the desired action or command.
  • "/d [{+|-}][{ | dd}]": Filters files based on their last modified date. You can specify a specific date, the operators "+" or "-" to search for dates after or before a certain date, or "dd" to search for files modified within the last number of days specified.

Overall, the "forfiles" command is a powerful tool to search, filter, and perform actions on files based on various criteria within a specific directory or its subdirectories.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the forfiles tool