Skip to content

Instantly share code, notes, and snippets.

@paulc
Last active December 19, 2016 23:33
Show Gist options
  • Select an option

  • Save paulc/aa94c6aecbaba6af9fa6339189141dca to your computer and use it in GitHub Desktop.

Select an option

Save paulc/aa94c6aecbaba6af9fa6339189141dca to your computer and use it in GitHub Desktop.
Fix timestamps for macOS Photos export
BEGIN {
n = split("January:February:March:April:May:June:July:August:September:October:November:December",months,":")
for (i=0;i<n;++i) {
rmonth[months[i+1]] = i+1
}
FS = " |/"
}
# Directory in format "[Event], yyyy month dd" or "yyyy month dd"
/[12][0-9][0-9][0-9]$/ {
yy = $NF
mm = $(NF-1)
dd = $(NF-2)
cmd = sprintf("touch -t %d%02d%02d1200 \"%s\"",yy,rmonth[mm],dd,$0)
print $0 " >> " cmd
system(cmd)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment