Skip to content

Instantly share code, notes, and snippets.

@kam1kaze
Created November 22, 2016 06:20
Show Gist options
  • Save kam1kaze/99a1a9528193c104b0965ae078dfe9d6 to your computer and use it in GitHub Desktop.
Save kam1kaze/99a1a9528193c104b0965ae078dfe9d6 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Example
# find ./ -type f -iname '*.jpg' | ./fix_date '+1388 days+9 hours'
set -o pipefail
set -o nounset
set -o errexit
# time difference
diff=$1
while read -r file; do
echo "Processing $file"
current=$(stat -c%w "$file")
echo " current: $(date -d "${current}" +'%D %X')"
new=$(date -d "${current}${diff}" +'%D %X')
echo " new: $new"
SetFile -d "$new" "$file"
done < /dev/stdin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment