Skip to content

Instantly share code, notes, and snippets.

@silverzhaojr
Last active February 10, 2026 11:24
Show Gist options
  • Select an option

  • Save silverzhaojr/fb3d79b419e3114544d34030cd7821b4 to your computer and use it in GitHub Desktop.

Select an option

Save silverzhaojr/fb3d79b419e3114544d34030cd7821b4 to your computer and use it in GitHub Desktop.
update photo modification date
# update photos from Camera
for file in $(find . -type f -name 'IMG*' -o -name 'Screenshot*' -o -name 'VID*'); do timestamp=$(echo "$file" | sed -E 's,.*/?(IMG|Screenshot|VID)_([0-9]{8})[-_]([0-9]{4})([0-9]{2}).*.(jpg|png|mp4),\2\3.\4,') ; echo touch -t "$timestamp" "$file" ; touch -t "$timestamp" "$file" ; done
# update pictures from Weixin
for file in $(find . -type f -name 'mmexport*'); do timestamp=$(date +'%Y%m%d%H%M.%S' -d @$(echo "$file" | sed -E 's,.*/?mmexport(1[0-9]{9})([0-9]{3})\.jpg,\1,')) ; echo touch -t $timestamp "$file" ; touch -t "$timestamp" "$file" ; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment