Given a directory with the following files
image1.txt
image2.txt
image3.txt
I want to get the oldest file (let the files be sorted by data, oldset date first):
dir /b /od c:\test\image?.txt | findstr ^1
That works great when manually typing it into cmd.exe. Now (in a batch script) I want to put the output of this command in a variable. How can I do this? Thank you!
Update: Wondering if there is a direct way without usng a loop?