Skip to content

Instantly share code, notes, and snippets.

@benjacoblee
Created November 1, 2023 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benjacoblee/32f111f659765fdb7f9a91ab6a0ba4f4 to your computer and use it in GitHub Desktop.
Save benjacoblee/32f111f659765fdb7f9a91ab6a0ba4f4 to your computer and use it in GitHub Desktop.
import std/private/osdirs
import std/os
import std/times
import std/algorithm
import std/terminal
import unpack
var table: seq[(string, Time)] = @[]
if paramCount() > 0:
commandLineParams().unpackSeq(path)
if dirExists(path):
try:
for fName in walkDirRec(path, skipSpecial = true):
var entry = (fName, getLastModificationTime(fName))
table.add(entry)
except OSError: discard
finally:
proc myCmp(x, y: (string, Time)): int =
var (_, t1) = x
var (_, t2) = y
cmp(t1, t2)
table.sort(myCmp)
for (fName, mTime) in table:
let dt = format(mTime, "yyyy-MM-dd HH:mm")
styledEcho fName, " ", styleBright, fgYellow, dt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment