#!/usr/bin/env bash # create a csv of path, file size, last access time for all files in a directory tree # usage: file-tree-csv.sh /path/to/directory > output.csv FILEDIR=/opt/moodledata/filedir cd $FILEDIR || (echo "Moodle filedir not found, exiting" && exit 1) echo "path,size,atime" # shellcheck disable=SC2044 # all Moodle file names & paths only contain hexadecimal chars for file in $(find . -type f); do size=$(stat -c %s $file) atime=$(stat -c %x $file) echo "$file,$size,$atime" done