Table of Contents

Exiftool

To see all available date/time fields in the file(s), use

exiftool -args -time:all *.jpg

Exif rename by date

Add the original Exif date to the beginning of the file name, and also move the file to a folder by year-month.

When using -testname instead of the real -filename, it only prints what it would do.

# set destination to a different path
dest=/path/to/by_month
 
# test what it would do
exiftool -d "$dest/%Y-%m/%Y-%m-%d_%%f-v%%02.c.%%e" '-testname<DateTimeOriginal' /path/to/process
 
# do it
exiftool -d "$dest/%Y-%m/%Y-%m-%d_%%f-v%%02.c.%%e" '-filename<DateTimeOriginal' /path/to/process

To also process subdirectories, add the -r (or -recurse) option

To only process files with a .jpg extension, use -ext jpg (case insensitive)

Example to rename all ".DNG" files in the current directory and it's subdirectories (without moving them):

exiftool -r -ext dng -d "%Y-%m-%d_%%f-v%%02.c.%%e" '-testname<DateTimeOriginal' .

Special variables in the -d specification:

After the Exif rename, remove the unneeded "-v00" extension in the destination:

find "$dest" -iname "*-v00.jpg" -exec rename -v 's/-v00(\.jpg)/$1/i' {} +

Set file time to Exif DateTimeOriginal

exiftool '-FileModifyDate<DateTimeOriginal' * 

or

exiftool -r -ext jpg '-FileModifyDate<DateTimeOriginal' /path/to/process

Copy JPEG Comment to Exif UserComment

For all .jpg files in current directory:

for f in *.jpg; do exiftool "-EXIF:UserComment<FILE:Comment" "$f"; done

Read specific tag

Use -Tagname to read just a specific tag. Add -b (-binary) option to not print the tag name. But then, there is no linefeed either! This example prints the "Title" and the "Filename", separated by a Tab and it uses echo and subshells so that a linefeed gets printed (there must be a better way, but I don't know it yet).

for f in *; do echo -e $(exiftool -Title -b "$f" 2>/dev/null)"\t"$(exiftool -Filename -b "$f" 2>/dev/null); done

See also