2018-08-28 10:23:45 +01:00
|
|
|
# forfiles
|
|
|
|
|
2024-01-25 05:28:11 +00:00
|
|
|
> Select files to execute a specified command on.
|
2022-10-04 16:06:23 +01:00
|
|
|
> More information: <https://learn.microsoft.com/windows-server/administration/windows-commands/forfiles>.
|
2018-08-28 10:23:45 +01:00
|
|
|
|
|
|
|
- Search for files in the current directory:
|
|
|
|
|
|
|
|
`forfiles`
|
|
|
|
|
|
|
|
- Search for files in a specific directory:
|
|
|
|
|
2023-02-20 07:23:49 +00:00
|
|
|
`forfiles /p {{path\to\directory}}`
|
2018-08-28 10:23:45 +01:00
|
|
|
|
|
|
|
- Run the specified command for each file:
|
|
|
|
|
|
|
|
`forfiles /c "{{command}}"`
|
|
|
|
|
|
|
|
- Search for files using a specific glob mask:
|
|
|
|
|
|
|
|
`forfiles /m {{glob_pattern}}`
|
|
|
|
|
|
|
|
- Search for files recursively:
|
|
|
|
|
|
|
|
`forfiles /s`
|
|
|
|
|
2018-08-29 11:01:26 +01:00
|
|
|
- Search for files older than 5 days:
|
2018-08-28 10:23:45 +01:00
|
|
|
|
2023-02-20 07:23:49 +00:00
|
|
|
`forfiles /d +{{5}}`
|