Skip to content

Instantly share code, notes, and snippets.

@jnx
Forked from jmuspratt/mediaName
Created February 23, 2021 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jnx/5d0655e6f40416b2b984018fe2e7b2c3 to your computer and use it in GitHub Desktop.
Save jnx/5d0655e6f40416b2b984018fe2e7b2c3 to your computer and use it in GitHub Desktop.
exiftool : rename files in current dir to YYYY-MM-DD-HH-MM-SS-1.ext
# Rename image and MOV files according to EXIF capture date, using YYYY-MM-DD-HH-MM-SS.ext
format.
# Files shot within the same second get copy number added (-1,-2, etc.).
# Video files require a different, so we run exiftool 3 times:
# 1. Exclude MOV files and rename the image files with <CreateDate>.
# 2. Target MOV files and rename them with MediaCreateDate (for iPhone videos).
# 3. Target MOV files and rename them with DateTimeOriginal (for Fuji camera videos).
# Requirements: install the package manager Homebrew (http://brew.sh), then install exiftool (type brew install exiftool in Terminal.app).
# Now open Terminal.app, cd to the relevant directory, and run the command.
# References:
# http://www.sno.phy.queensu.ca/~phil/exiftool/
# http://ninedegreesbelow.com/photography/exiftool-commands.html#rename
# http://www.polaine.com/2015/01/fixing-photo-and-video-file-metadata-with-exiftool/
# Note: --ext EXCLUDES files with the extension, while -ext INCLUDES files with that extension
exiftool --ext MOV '-filename<CreateDate' -d %Y-%m-%d-%H-%M-%S%%-c.%%le .; exiftool -ext MOV '-filename<ContentCreateDate' -d %Y-%m-%d-%H-%M-%S%%-c.%%le .; exiftool -ext MOV '-filename<DateTimeOriginal' -d %Y-%m-%d-%H-%M-%S%%-c.%%le .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment