Skip to content

Instantly share code, notes, and snippets.

@royashbrook
Created February 28, 2018 17:09
Show Gist options
  • Save royashbrook/95b6d08f17d0910243c6f3c6e7934d70 to your computer and use it in GitHub Desktop.
Save royashbrook/95b6d08f17d0910243c6f3c6e7934d70 to your computer and use it in GitHub Desktop.
# all files
$a = Get-Item *.txt
# prefix of latest file
$b = $a |
sort -Property LastWriteTime -Descending |
select -First 1 @{n='dts';e={$_.name.split('_')[0]}}).dts
# files with that prefix
Get-Item "$b*.txt"
# one-liner that I actually did
(Get-Item ("{0}*.txt" -f $((Get-Item *.txt) |
sort -Property LastWriteTime -Descending |
select -First 1 @{n='dts';e={$_.name.split('_')[0]}}).dts))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment