forfiles.exe behavior.

Doria 1,246 Reputation points
2020-12-03T19:46:42.637+00:00

Hi everyone!

Is there a way to make '%SystemRoot%\system32\forfiles.exe / D -90' command sees the creation date of the file I just copied to a folder instead of creation date of the file itself? In other words, I copy a file that was created a long time ago to a folder and the copy keeps the old date of the file. If I use 'dir /T:C' command I can see real date the file was created in the folder. Perhaps, when I use '%SystemRoot%\system32\forfiles.exe / D -90' command it deletes the file I just copied?!!! What?

Hope I was clear enough.

Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
13,727 questions
0 comments No comments
{count} votes

Accepted answer
  1. Ian Xue-MSFT 40,431 Reputation points Microsoft External Staff
    2020-12-04T07:32:11.337+00:00

    Hi,

    The forfiles.exe works with the last modified dates, not the creation dates. To get the files created more than 90 days ago you can try the powershell command

    Get-ChildItem -Path "C:\Folder" -File | Where-Object {$_.CreationTime -lt (Get-Date).AddDays(-90)}  
    

    Best Regards,
    Ian

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Doria 1,246 Reputation points
    2020-12-04T12:46:06.497+00:00

    Got it, moving to PS...

    Thanks

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.