Skip to content

Instantly share code, notes, and snippets.

@tatze
Last active February 5, 2023 13:12
Show Gist options
  • Save tatze/ddd44e4eac3a72148847ad06a2a4f052 to your computer and use it in GitHub Desktop.
Save tatze/ddd44e4eac3a72148847ad06a2a4f052 to your computer and use it in GitHub Desktop.
find images and movies recursively and rename them by prepending their EXIF timestamp
# add trailing timestamps when missing
# needs: exiftool
#
# Regular files
find . -iregex '.*\.jpe?g$' -not -regex '.*/[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9][0-9][0-9].*' -exec exiftool -q -d "%Y%m%d_%H%M%S-%%f.%%e" "-filename<createdate" {} \;
find . -iregex '.*\.mp4$' -not -regex '.*/[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9][0-9][0-9].*' -exec exiftool -q -d "%Y%m%d_%H%M%S-%%f.%%e" "-filename<createdate" {} \;
#
# Apple files
find . -iregex '.*\.HEIC$' -not -regex '.*/[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9][0-9][0-9].*' -exec exiftool -q -d "%Y%m%d_%H%M%S-%%f.%%e" "-filename<createdate" {} \;
find . -iregex '.*\.mov$' -not -regex '.*/[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9][0-9][0-9].*' -exec exiftool -q -d "%Y%m%d_%H%M%S-%%f.%%e" "-filename<creationdate" {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment