CommandLineFu: FileType Report w/ Dates

More find magic — this little beast takes a while to run on large directories but is worth it’s weight in gold.  Now I just need a way to convert Epoch time to YYYYMMDD format inline. (New project)

find ./foo/ -type f -printf '%f|%h|%s|%AY%Am%Ad|%TY%Tm%Td|' -exec stat --printf "%W|" '{}' \; -exec file -bp '{}' \; > bar.log

%f == file name without leading directories

%h == leading directories without file name

%s == size in bytes

%A = Last access time (Y,m,D = YYYYMMDD format)

%T == Modification time (Y,m,D = YYYYMMDD format)

(using printf keeps everything on the same line)

stat %W == file birth date in Epoch time

file -bp == checks file type, b==brief, p==preserve date

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s