How can I batch shift the creation date of files on OS X 10.6.8?
touch only changes the creation time if the target modification time is before the original creation time.
for f in ~/Desktop/*; do
old=$(stat -f %B -t %s "$f")
touch -t $(date -r $(($old - 1234567)) +%Y%m%d%H%M%S) "$f"
done
SetFile always changes the creation time. It comes with the command line tools package that can be downloaded from Xcode's preferences or Apple's website.
for f in ~/Desktop/*; do
old=$(stat -f %B -t %s "$f")
new=$(date -r $(($old + 1234567)) '+%m/%d/%Y %H:%M:%S')
SetFile -d "$new" -m "$new" "$f"
done
stat -f %B -t %s
: format birth time, time format seconds since epoch
date -r
: reformat seconds since epoch
touch -t
: change access and modification times
SetFile -d
: change creation time