Skip to content

Instantly share code, notes, and snippets.

@connormclaud
Created February 14, 2024 16:34
Show Gist options
  • Save connormclaud/32fd7684973a18b2f6121d556f47ba2e to your computer and use it in GitHub Desktop.
Save connormclaud/32fd7684973a18b2f6121d556f47ba2e to your computer and use it in GitHub Desktop.
extend dropbox status with list of files changed in last 24h
#!/bin/bash
# Change to your Dropbox directory
cd ~/Dropbox
/usr/bin/dropbox status
# Find files modified in the last day and print their last modification time
find . -type f -mtime -1 -print0 | while IFS= read -r -d '' file; do
mod_time=$(date -r "$file" +"%Y-%m-%d %H:%M:%S")
time_ago=$(echo $(($(date +%s) - $(date +%s -r "$file"))))
# Convert time to a human-readable format
if [ $time_ago -lt 60 ]; then
printf "%-50s - updated just now\n" "$file"
elif [ $time_ago -lt 3600 ]; then
printf "%-50s - updated %2d minutes ago\n" "$file" $((time_ago / 60))
else
printf "%-50s - updated %2d hours ago\n" "$file" $((time_ago / 3600))
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment