Skip to content

Instantly share code, notes, and snippets.

@ghotz
Last active July 12, 2024 18:11
Show Gist options
  • Save ghotz/68d925ff172d30c4b172efe041f6d65f to your computer and use it in GitHub Desktop.
Save ghotz/68d925ff172d30c4b172efe041f6d65f to your computer and use it in GitHub Desktop.
Exiftool copy & paste snippets

Exiftool snippets

General

To recurse sub-directories, add -r, specify . and filter by extension.

Filtering only some extensions:

  • photos -ext jpg -ext orf -ext ori -ext dng -ext heic -ext PEF -ext RAF -ext SRF -ext NEF -ext X3F -ext KDC
  • videos -ext mp4 -ext mov -ext mts -ext avi
  • sidecar -ext xmp -ext mie

To display tag names, instead of descriptions, add -s

SRF files (old Sony cameras RAW e.g. DSC-F828), KDC files (old Kodak cameras RAW e.g. P880) can't be updated by Exiftool, so changes to metadata needs to be recorder in MIE and/or XMP sidecar files.

X3F files (RAW Sigma) is updated, but Lightroom won't read some tags (e.g. EXIF:Artist)

Dates manipulation

Assign Exif create/modify dates to respective file date properties

exiftool "-FileCreateDate<Exif:CreateDate" "-FileModifyDate<Exif:ModifyDate" *

Assign Exif create date to both create/modify file date properties

exiftool "-FileCreateDate<Exif:CreateDate" "-FileModifyDate<Exif:CreateDate" *

Fix daylight saving

Fix all dates from standard time to DST

exiftool -overwrite_original "-AllDates+=00:00:00 01:00:00" *

Fix all dates from DST to standard time

exiftool -overwrite_original "-AllDates-=00:00:00 01:00:00" *

File names manipulation

Original file names preservation

Save current filename to preserve filename tag

exiftool -overwrite_original "-PreservedFileName<Filename" *

Rename files according to original preserved filename in tag

exiftool -overwrite_original "-Filename<PreservedFileName" *

Rename files preserving the original file name and adding in front creation date and time from Exif tag

exiftool -d "%Y%m%d-%H%M%S-%%f.%%e" "-filename<Exif:CreateDate" *

Rename files preserving the original file name and adding in front creation date and time from Quicktime tag

exiftool -d "%Y%m%d-%H%M%S-%%f.%%e" "-filename<QuickTime:CreateDate" *

Lens manipulation

Add manual lens information

Add lens information for TTArtisan APS-C 35mm F1.4 to Fujifilm X-T1

exiftool -overwrite_original -if "not $LensID" -LensMake="TTArtisan" -LensModel="APS-C 35mm F1.4" -FocalLength="35" -MaxApertureValue="1.4" -FocalLengthIn35mmFormat="52" -LensInfo="35 35 1.4 16" -ext jpg -ext raf *

Add lens information for Pentax SMC Pentax-M 50mm F1.7 to Pentax K10D

exiftool -overwrite_original -if "$LensID eq 'K or M Lens'" -LensMake="Pentax" -LensModel="SMC Pentax-M 50mm F1.7" -FocalLength="50" -MaxApertureValue="1.7" -FocalLengthIn35mmFormat="76.5" -LensInfo="50 50 1.7 22" -LensFocalLength="50" -ext jpg -ext dng -ext pef *

Add lens information for Pentax SMC Pentax-M 50mm F1.7 to Fujifilm X-T1

exiftool -overwrite_original -if "not $LensID" -LensMake="Pentax" -LensModel="SMC Pentax-M 50mm F1.7" -FocalLength="50" -MaxApertureValue="1.7" -FocalLengthIn35mmFormat="76.5" -LensInfo="50 50 1.7 22" -LensFocalLength="50" -ext jpg -ext raf *

Add lens information for Tamron AF 70-300mm F4-5.6 LD Macro 1:2 to Fujifilm X-T1

exiftool -overwrite_original -if "not $LensID" -LensMake="Tamron" -LensModel="Tamron AF 70-300mm F4-5.6 LD Macro 1:2" -FocalLengthIn35mmFormat="200" -LensInfo="70 300 4 32" -LensFocalLength="300" -ext jpg -ext raf *

Origin manipulation

Credits manipulation

Add EXIF:Artist, IPTC:By-line and XMP-dc:Creator

exiftool -overwrite_original -"exif:Artist=Gianluca Hotz" -"iptc:By-line=Gianluca Hotz" -"XMP-dc:Creator=Gianluca Hotz" *

Output list of files without EXIF Copyright

exiftool -if "not $exif:Copyright" -filename *

Output list of files in a directory named Unknown Author and XMP By-Line assigned

exiftool -if "$directory =~ /Unknown Author/i" -if "not $iptc:By-Line" -filename *

Copy XMP-dc:Creator to EXIF:Artist and IPTC:By-line

exiftool -overwrite_original -if "$XMP-dc:Creator" -if "not $exif:Artist" -"exif:Artist<XMP-dc:Creator" *

exiftool -overwrite_original -if "$XMP-dc:Creator" -if "not $iptc:By-line" -"iptc:By-line<XMP-dc:Creator" *

Copy XMP-dc:Rights to EXIF:Copyright and IPTC:CopyrightNotice

exiftool -overwrite_original -if "$XMP-dc:Rights" -if "not $exif:Copyright" -"exif:Artist<XMP-dc:Rights" *

exiftool -overwrite_original -if "$XMP-dc:Rights" -if "not $iptc:CopyrightNotice" -"iptc:CopyrightNotice<XMP-dc:Rights" *

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