0

I'm trying to catch all the files in a folder taking in account two filters, the first one is the creation date have to be greater than 01/01/2020 and the creation date have to be lower that today-6.

I don't know how to apply two filters in the same forfiles command line. This is what I have:

forfiles /P c:\temp /D +01/01/2020 /C "cmd /c echo @path"
aschipfl
  • 33,626
  • 12
  • 54
  • 99
  • Use PowerShell instead of trying to get a scripting language to perform tasks it was never designed to do. Also forfiles.exe, only works with last written/modified dates and times, not creation dates and times. There should be plenty of questions and answers with the [[tag:powershell]] tag, which can identify file objects within a created date/time range. Please use the search facility to adapt one or more to your needs. – Compo Oct 21 '22 at 16:04

1 Answers1

0

Well, forfiles doesn't filter for the creation date, rather does it regard the last modification date (though not the time), and it supports only a single such filter.

However, you may nest two commands:

forfiles /P "C:\TEMP" /D +01/01/2020 /C "forfiles forfiles /P @path\.. /M @file /D -6 /C 0x22cmd /D /C if @isdir==FALSE echo 00x7840path0x22" 2> nul

Note, that the expected date format behind /D depends on the actual locale settings.

Also refer to this post: FORFILES date -after- (date calc in cmd file)

aschipfl
  • 33,626
  • 12
  • 54
  • 99