Created
February 14, 2024 16:34
-
-
Save connormclaud/32fd7684973a18b2f6121d556f47ba2e to your computer and use it in GitHub Desktop.
extend dropbox status with list of files changed in last 24h
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
#!/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