Skip to content

Instantly share code, notes, and snippets.

@tallpeak
Created May 19, 2020 16:18
Show Gist options
  • Save tallpeak/eb14e40833cdd00518df7b4eec008b88 to your computer and use it in GitHub Desktop.
Save tallpeak/eb14e40833cdd00518df7b4eec008b88 to your computer and use it in GitHub Desktop.
Summary of file sizes for a directory tree, by extension
using Printf
using Formatting
d=Dict{String, Integer}()
for (root, dirs, files) in walkdir(".")
for file in files
ff=joinpath(root, file)
fs=filesize(ff)
ar=rsplit(file,".";limit=2)
ext=pop!(ar)
nw=Dict(ext => fs)
merge!(+,d,nw)
end
end
d = [ (c,w) for (w,c) in d ]
sort!(d)
for (k,v) in d
@printf("%s %s\n",lpad(format(k,commas=true),13),v)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment