forfiles
- это исполняемый файл, используемый в основном вместе с cmd.
Проблема в формате даты. Согласно справке forfiles /?
, следуйте формату "dd.MM.yyyy". Это может зависеть от локали системы, поэтому проверьте справку вашей установки;Мой говорит:
/D date Selects files with a last modified date greater
than or equal to (+), or less than or equal to
(-), the specified date using the
"dd.MM.yyyy" format; or selects files with a
last modified date greater than or equal to (+)
the current date plus "dd" days, or less than or
equal to (-) the current date minus "dd" days. A
valid "dd" number of days can be any number in
the range of 0 - 32768.
"+" is taken as default sign if not specified.
Что касается решения Powershell, используйте Get-ChildItem
и фильтр на основе CreationDate
, например, так:
Get-ChildItem c:\temp | ? {$_.CreationTime -ge (Get-Date).AddDays(-5)}
Это будет получить список каталогов и выбрать файлывремя создания которого больше или равно дате пять дней назад.