I have been trying without success to transfer the creation date from one file to another on OS X 10.8 (Mountain Lion) using Bash. It’s probably some combination of stat
and touch
but I haven’t quite figured it out, because the format used by stat does not match that needed by touch.
This is what I tried so far. It’s part of a video conversion script which obliterates the creation date:
for f in "$@"
do
# convert video
HandBrakeCLI -i "$f" -o "/Users/J/Desktop/$(basename $f .AVI).mp4" -e x264 -q 20 -B 160
# read out creation date from source file
date_transfer=$(stat -f "%Sm" "$f") # output e.g.: Oct 27 16:33:41 2013
# write creation date of source to converted file
touch -t $date_transfer /Users/J/Desktop/$(basename $f .AVI).mp4 # requires 201310271633 instead
done