Skip to content

Instantly share code, notes, and snippets.

@liaocs2008
Last active October 21, 2022 03:18
Show Gist options
  • Save liaocs2008/62332e334999264e985fea162c13ab31 to your computer and use it in GitHub Desktop.
Save liaocs2008/62332e334999264e985fea162c13ab31 to your computer and use it in GitHub Desktop.
sort images by names via modifying timestamp for google photos
# after running the script, use google photos their built-in timestamp based sorting function
i=0
find ./ -name "*.jpg" | sort | while read filename; do
i=$((i+1))
time=`date --date="-${i} seconds" '+%Y:%m:%d-%T'`
#echo $time
jhead -mkexif $filename
jhead -ts$time $filename
jhead -ta-128:00 $filename # add extra hour offset if necessary
# following won't work
#time=`echo "${time//:/}"`
#time=${time:0:12}
#touch -t $time "$filename"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment