Created
July 16, 2024 19:20
-
-
Save phette23/35b51af01865b92f07314843d3a0fe6c to your computer and use it in GitHub Desktop.
create CSV of file paths, size, and last accessed times for Moodle filedir
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
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment