Delete file with the same name with the oldest date

I have a folder that will always have 2 files with the same name, I would like to create a logic to always delete the file with older date, could someone help me?

In order to get the ‘Date Modified’ property of a file, use this:
Assign that to a variable.
Change the file path.
Then compare.

Thanks and best of luck!

Another way is read the files in the folder via a ForEach loop

ForEach File in directory.getfiles("YourFolderPath)

Assign FileMetdata = new FileInfo(file)

WriteLine FileMetadata.LastWriteTime.ToString

I was able to get the oldest file but how would I make a condition to delete it?

datecompare.xaml (5.3 KB)
You may want to try this one :slight_smile: