Answer the question
In order to leave comments, you need to log in
How to quickly find the newest file in a folder?
there was a task to delete the old files from the folder, the modification date of which is more than the modification date of the newest file in this folder by X days. There can be many, many hundreds of thousands of files there. The question is how to find the newest file using api in the minimum time / resources.
Answer the question
In order to leave comments, you need to log in
Use the search by folder in the search criteria, set the modification date
I don’t know about api, your task is easily solved by a script.
for example powershell:
$files=Get-ChildItem * -File | sort -Descending CreationTime
$date=$files[0].CreationTime.AddDays(-50)
$files | where {$_.CreationTime -le $date} | Foreach {Write-host $_.FullName}
FindFirstFile + FindNextFile + FindClose. For each found file - GetFileTime
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question