Skip to content

Instantly share code, notes, and snippets.

@dnozay
Forked from rjames86/My Exiftool Cheatsheet.md
Last active March 16, 2026 01:01
Show Gist options
  • Select an option

  • Save dnozay/955037f077b6dec87aa9b1eb552caf8d to your computer and use it in GitHub Desktop.

Select an option

Save dnozay/955037f077b6dec87aa9b1eb552caf8d to your computer and use it in GitHub Desktop.
Cheatsheet for image / video metadata manipulation.

Last updated: 2014-09-28

Searching for Files

Find images in a directory that don't have a DateTimeOriginal

exiftool -filename -filemodifydate -createdate -r -if '(not $datetimeoriginal) and $filetype eq "JPEG"' .

Output photos that don't have datetimeoriginal to a CSV
Note this can take a long time if you have a lot of jpgs

# You'll need to set your Dropbox folder path. I have mine set as a global variable
OLDFILE="$DROPBOX_PERSONAL/nodates.csv"

FILECOUNT=$(mdfind -count -onlyin "$DROPBOX_PERSONAL" 'kMDItemKind =="JPEG image"')
while IFS= read -r -d '' n; do
    FILECOUNT=$(( $FILECOUNT - 1 ))
    if grep -q "$n" "$OLDFILE"; then
        echo "Skipping $n"
        continue
    fi

    echo -ne "Remaining: $FILECOUNT\r"
    exiftool -q -if '(not $datetimeoriginal or ($datetimeoriginal eq "0000:00:00 00:00:00"))' -csv -common "$n" | sed 1d >> "$DROPBOX_PERSONAL/nodates.csv"
done < <( mdfind -onlyin "$DROPBOX_PERSONAL" 'kMDItemKind =="JPEG image"' -0 )

See files File Modify Date recursively in a directory who don't have datetimeoriginal set

exiftool -filemodifydate -r -if '(not $datetimeoriginal or ($datetimeoriginal eq "0000:00:00 00:00:00")) and ($filetype eq "JPEG")' .

Modifying Files

Change JPG to jpg and MOV to mov in filenames

for i in *.JPG; do mv "$i" "${i%%.JPG}.jpg"; done; !#:gs/JPG/MOV/:gs/jpg/mov/

Change last created and modified for files in a directory

The date syntax has to be YYYY:MM:DD HH:MM:SS

Option 1:

find . -name "*.jpg" | while read filename;  
    exiftool "-AllDates=1986:11:05 12:00:00" "$filename";
done

Option 2:

exiftool "-AllDates=1986:11:05 12:00:00" -if '$filetype eq "JPEG"' .

Rename files to datestamp

Filename looks like 2014-01-01 12:00:00.jpg and will append -NUM if DateTimeOriginal is the same for multiple files

exiftool '-FileName<DateTimeOriginal' -d "%Y-%m-%d %H.%M.%S%%-c.%%e" .  

Update any photo that doesn't have DateTimeOriginal to have it based on file modify date

exiftool '-datetimeoriginal<filemodifydate' -if '(not $datetimeoriginal or ($datetimeoriginal eq "0000:00:00 00:00:00")) and ($filetype eq "JPEG")' .
@dnozay
Copy link
Author

dnozay commented Jul 24, 2019

@dnozay
Copy link
Author

dnozay commented Jul 24, 2019

http://u88.n24.queensu.ca/exiftool/forum/index.php?topic=8359.0

exiftool -if '$ShutterCount' '-FileName<${ShutterCount; $_ = substr("000000$_",-6);}.%e' -r DIR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment