Reputation: 53223
If I have a full-path with a wildcard, how can I get the file with the oldest LastWriteTime?
$fullpath = "myFolder:\foooBar*.txt"
$theOldestFile = # What to write to get among the
#fooBar*.txt that has the max LastWriteTime?
Upvotes: 3
Views: 12695
Reputation: 60910
like this:
$fullpath = "myFolder:\foooBar*.txt"
$theOldestFile = dir $fullpath | sort lastwritetime | select -First 1
Upvotes: 10