Blog of Suresh Kumar Nalluru

30 Apr 2018

Exiftool

exiftool is a wonderful tool if you like custom renaming of files. It also supports HEIC files (the default format for apple iphones) these days. sample usages below.

Rename jpg etc based on DateTimeOriginal exif tag inside the image

1exiftool -r '-FileName<DateTimeOriginal' -d %Y/%m/%Y-%m-%d_%H-%M-%S%%-c.%%e  -ext JPG -ext PNG -ext jpeg -ext HEIC  -ext GIF .

For files which dont have DateTimeOriginal tag rename jpg etc based on FileModifyDate

1exiftool -r "-FileName<FileModifyDate" -d 'Unknown/%%f%%-c.%%e' -if 'not $DateTimeOriginal' -ext JPG -ext PNG -ext jpeg -ext HEIC -ext GIF .

Rename Video files based on MediaCreateDate exif tag inside the video

1exiftool -r '-FileName<MediaCreateDate' -d %Y/%m/%Y-%m-%d_%H-%M-%S%%-c.%%e -ext MOV -ext mp4 -ext MP4 .

For files which dont have MediaCreateDate tag rename movie etc based on FileModifyDate

1exiftool -r "-FileName<FileModifyDate" -d 'Unknown/%%f%%-c.%%e' -if 'not $MediaCreateDate' -ext MOV -ext mp4 -ext MP4 .

For some files have MediaCreateDate tag set to 00 rename movie etc based on FileModifyDate

1exiftool -r "-FileName<FileModifyDate" -d 'Unknown/%%f%%-c.%%e' -if '$MediaCreateDate eq "0000:00:00 00:00:00"' -ext MOV -ext mp4 -ext MP4 .