Skip to content

Instantly share code, notes, and snippets.

@ghotz
Last active May 2, 2025 07:03
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

CLI snippets

Image Conversion

Convert all JPGs in a directory to JPG XL with lossless conversion

for /R %i in (*.jpg) do cjxl.exe --lossless_jpeg=1 "%i" "%~dpni.JXL"

Convert all TIFFs in a directory to JPG XL with lossless conversion copying metadata (ImageMagick, worse)

for /R %i in (*.tif) do (magick -quality 100 "%i" "%~dpni.JXL" && exiftool -tagsfromfile "%i" -all:all -unsafe "%~dpni.JXL")

Convert all TIFFs in a directory to JPG XL with lossless conversion copying metadata (Vips)

set VIPS_WARNING=1 && for /R %i in (*.tif) do (vips jxlsave "%i" "%~dpni.JXL" --lossless && exiftool -tagsfromfile "%i" -all:all -unsafe "%~dpni.JXL")

Convert all TIFFs in a directory to ZIP compressed TIF copying metadata (Vips)

set VIPS_WARNING=1 && for /R %i in (*.tif) do (ren "%i" "%~ni.TMP" && vips tiffsave "%~dpni.TMP" "%~dpni.TIF" --compression deflate && exiftool -tagsfromfile "%~dpni.TMP" -all:all -unsafe "%~dpni.TIF" && del "%~dpni.TMP")

Exiftool snippets

General

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

Filtering only some extensions:

  • photos -ext JPG -ext JXL -ext HEIC -ext ORF -ext ORI -ext DNG -ext PEF -ext RAF -ext SRF -ext NEF -ext X3F -ext KDC -ext MRW -ext ARW -ext CRW
  • videos -ext MP4 -ext MOV -ext MTS -ext AVI
  • sidecar -ext XMP -ext MIE -ext EXIF -ext EXV -ext AAE -ext THM

In general, use -ext with -r to recurse directories and . instead of * to start from the current one.

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

To display raw values add -n

To decompress zip/bzip compressed file add -z

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)

Backup/Restore

Backup all metadata to MIE proprietary (zipped) file including all supported files but excluding metadata files

exiftool -z -o %f.%e.MIE --ext MIE --ext XMP --ext EXIF --ext EXV --ext AAE --ext THM *

Backup all metadata to MIE proprietary (zipped) files including only image files (add your own...)

exiftool -z -o %f.%e.MIE -ext JPG -ext JXL -ext HEIC -ext ORF -ext ORI -ext DNG -ext PEF -ext RAF -ext SRF -ext NEF -ext X3F -ext KDC -ext MRW -ext ARW -ext CRW *

Restores REPLACING all metadata from MIE proprietary files to sidecar JPG images (WARNING: uses unsafe option)

exiftool -overwrite_original -all= -tagsfromfile %f.%e.MIE -all:all -unsafe -ext JPG *

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" *

Assign Quicktime create/modify dates to respective file date properties

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

Assign modify file date to all other dates properties (fix Whatsapp saved to iphoto album)

exiftool -overwrite_original "-allDates<FileModifyDate" "-FileCreateDate<FileModifyDate" *

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" *

Set all dates to a single reference date assigning "wrong date" keyword

exiftool -overwrite_original "-AllDates=2001-01-01 00:00:00" "-keyword=wrong date" *

Change all QuickTime dates of interest to local time based on time zone in CreationDate tag

exiftool -extractEmbedded -if "defined $QuickTime:CreationDate" "-QuickTime:CreateDate<${CreationDate#;s/ ?[+-]\d{2}:\d{2}$//}" "-QuickTime:ModifyDate<${CreationDate#;s/ ?[+-]\d{2}:\d{2}$//}" "-QuickTime:TrackCreateDate<${CreationDate#;s/ ?[+-]\d{2}:\d{2}$//}" "-QuickTime:TrackModifyDate<${CreationDate#;s/ ?[+-]\d{2}:\d{2}$//}" "-QuickTime:MediaCreateDate<${CreationDate#;s/ ?[+-]\d{2}:\d{2}$//}" "-QuickTime:MediaModifyDate<${CreationDate#;s/ ?[+-]\d{2}:\d{2}$//}" -overwrite_original *.mov

Change all QuickTime dates of interest to UTC based on time zone in CreationDate tag

exiftool -extractEmbedded -api QuickTimeUTC -if "defined $QuickTime:CreationDate" "-QuickTime:CreateDate<QuickTime:CreationDate" "-QuickTime:ModifyDate<QuickTime:CreationDate" "-QuickTime:TrackCreateDate<QuickTime:CreationDate" "-QuickTime:TrackModifyDate<QuickTime:CreationDate" "-QuickTime:MediaCreateDate<QuickTime:CreationDate" "-QuickTime:MediaModifyDate<QuickTime:CreationDate" -overwrite_original *.mov

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

Pentax SMC Pentax-M 50mm F1.7

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, X-Pro1

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 Pentax SMC Pentax-M 50mm F1.7 to Olympus E-1, E-300, E-M1 MK3

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

TTArtisan APS-C 35mm F1.4

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

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 *

Tamron AF 70-300mm F4-5.6 LD Macro 1:2

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

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" *

Hacks

Fujifilm hacks

Changing camera to trick Capture One into using newer Film Simulations

Notes:

  • Although simulations are applied also to X-Trans sensors I and II, they are really only supported for X-Trans III+
  • Switching back to the original camera metadata result in Capture One processing the image in a different way

Get original information regarding camera model:

exiftool -model -software -ext RAF *

Change metadata to newest model (check on Fuji site for latest firmware version number):

exiftool -model="X-T5" -software="Digital Camera X-T5 Ver4.00" -ext RAF *

Change metadata to original model(S):

  • X-Pro1 3.70: exiftool -model="X-Pro1" -software="Digital Camera X-Pro1 Ver3.70" -ext RAF *
  • X-Pro1 2.82: exiftool -model="X-Pro1" -software="Digital Camera X-Pro1 Ver3.82" -ext RAF *
  • X-T1: exiftool -model="X-T1" -software="Digital Camera X-T1 Ver5.52" -ext RAF *

Survival kit for lame implementations

Apple Live Photos

Recursively find iphone videos not related to Live Photos (without correlation ID)

exiftool -r -if "$Model=~/iPhone.*/" -if "not $ContentIdentifier" -filename -ext mov -ext mp4 *

Recursively find iphone Live Photos videos and images (with correlation ID)

exiftool -r -if "$Model=~/iPhone.*/" -if "defined $ContentIdentifier" -ContentIdentifier -ext mov -ext mp4 -ext heic -ext jpg *

Custom Workflow

Copy metadata from base JPG sidecars in 16-bit no-exif TIFF files (e.g. Olympus Studio)

exiftool -overwrite_original -tagsfromfile %27f.JPG -all:all -unsafe -ext TIF *

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