Created
May 19, 2020 16:18
-
-
Save tallpeak/eb14e40833cdd00518df7b4eec008b88 to your computer and use it in GitHub Desktop.
Summary of file sizes for a directory tree, by extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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