Calabi Labs · Guide · 2026-06-21

Advanced exiftool

Advanced exiftool

Advanced ExifTool: Complete Command Reference & Expert Techniques

ExifTool is the most powerful metadata manipulation tool available—but most users only scratch the surface. This guide covers the advanced workflows, scripting patterns, and edge-case handling that separate casual users from professionals.

1. Understanding ExifTool's Architecture

Before diving into commands, understand how ExifTool processes files:

This architecture means you can read without risk and craft surgical edits.

2. Advanced Reading Techniques

2.1 Extracting Specific Metadata Groups

```bash

Extract only GPS data

exiftool -gps:all -n -csv photos/ > gps_data.csv

Extract EXIF, IPTC, and XMP together, formatted for readability

exiftool -a -s -G:1 image.jpg

Read embedded metadata from a video

exiftool -ee -three -Api:all video.mp4 ```

2.2 Conditional Extraction with Grep

```bash

Find all photos taken with a specific lens

exiftool -if '$LensID =~ /85mm/' -filename -datesuboriginal .

Extract images with GPS but missing city tag

exiftool -if '$gpslatitude and not $City' -filename -ext jpg . ```

2.3 Binary Data Extraction

```bash

Dump thumbnail to external file

exiftool -b -ThumbnailImage photo.jpg > thumbnail.jpg

Extract embedded preview image from RAW files

exiftool -b -PreviewImage -w !%d%f_preview.jpg -ext nef . ```

3. Advanced Writing Operations

3.1 Conditional Updates

```bash

Only update copyright if it's currently empty

exiftool -if 'not defined $Copyright' -Copyright="Your Name" .

Replace lens name only for Tamron lenses

exiftool -if '$LensModel =~ /Tamron/' -LensModel="Tamron SP 24-70mm" .

Batch adjust GPS coordinates (shift by offset)

exiftool -if '$gpslatitude' -gpslatitude+=0.05 -gpslongitude+=0.03 . ```

3.2 Date/Time Manipulation

```bash

Shift all dates forward by 1 hour (for DST correction)

exiftool -alldates+=1:00 photos/

Set specific date to EXIF Original, then offset CreateDate

exiftool -DateTimeOriginal="2024:06:15 10:30:00" \ -CreateDate+=0:0:0 2:30:00 \ -ModifyDate+=0:0:0 2:30:00 file.jpg

Extract and normalize dates across formats

exiftool "-DateTimeOriginal>FileModifyDate" . ```

3.3 Complex GPS Operations

```bash

Convert decimal to DMS format and write

exiftool -gpslatitude=40.7128 -gpslongituderef=W -gpslongitude=74.006 \ -gpslatituderef=N photo.jpg

Strip GPS from all files except those in a specific folder

exiftool -if '$filename =~ /keep_location/' -gps:all= -r photos/

Calculate distance between two photos' GPS points (requires calculation script)

```

4. Batch Processing Patterns

4.1 Parallel Processing for Large Datasets

```bash

Use GNU parallel for multi-core processing

find /photos -type f -name "*.jpg" | parallel -j4 'exiftool -overwrite_original -Artist="Name" {}'

Process by directory with preserved structure

exiftool -r -overwrite_original '-Directory<${directory;s/old/new/}' /source/ ```

4.2 Pipeline Operations

```bash

Find and tag files based on filename pattern

for f in *.JPG; do year=$(echo "$f" | cut -d_ -f1) exiftool -overwrite_original -keywords+="$year" "$f" done

Chain ExifTool with ImageMagick for processing

exiftool -b -JpgFromRaw $file | magick - -resize 800x600 thumb.jpg ```

4.3 Template-Based Batch Editing

```bash

Create metadata template file

cat > template.args << 'EOF' -Artist=John Doe -Copyright=© 2024 -Keywords+=Portfolio -XMPToolkit= EOF

Apply template to multiple files

exiftool @template.args -r photos/ ```

5. Professional Workflows

5.1 Privacy-Preserving Workflow

```bash

Complete metadata scrub for sharing

exiftool -all= -overwrite_original \ -ICC_Profile:all= \ -XMP-xmpMM:DocumentID= \ -r public_photos/

Selective preservation (keep color profile, strip identifying info)

exiftool -overwrite_original \ -gps:all= \ -exif:all= \ -Make= \ -Model= \ -SerialNumber= \ -OwnerName= \ -ImageUniqueID= \ public_photos/ ```

5.2 RAW Workflow Integration

```bash

Embed metadata into RAW files without touching image data

exiftool -overwrite_original_in_place \ -Copyright="Studio Name" \ -Artist="Photographer" \ -Credit="Studio Name" \ -Contact="[email protected]" \ -CopyrightNotice="All rights reserved" \ .NEF .CR2 *.ARW

Sidecar file management

exiftool -ext xmp -r dir/ # Reads/writes sidecar files automatically ```

5.3 Video Metadata Handling

```bash

Extract frame at timestamp and write GPS to video

exiftool -overwrite_original \ -geotag track.gpx \ -ext mp4 -ext mov .

Remove all metadata from video for file size reduction

exiftool -all= -overwrite_original video.mp4

Set duration-based timestamps

exiftool -MediaCreateDate="2024:01:15 12:00:00" video.mov ```

6. Advanced Tags & Groups

6.1 XMP Custom Fields

```bash

Write custom XMP schema fields

exiftool -xmp-dc:Subject-="old-keyword" \ -xmp-dc:Subject+="new-keyword" \ photo.jpg

Create custom namespace for proprietary metadata

exiftool -xmp-pkg:ProjectCode="ABC123" \ -xmp-pkg:ClientID="XYZ-789" \ photo.jpg ```

6.2 Hierarchical IPTC Processing

```bash

Set location hierarchy (Country, Province, City)

exiftool -IPTC:Country-PrimaryCodeName=USA \ -IPTC:Province-State="California" \ -IPTC:City=Pasadena \ -IPTC:Sub-location="Old Town" \ photo.jpg

Write to both IPTC and XMP for maximum compatibility

exiftool -common \ -IPTC:Headline="..." \ -XMP-dc:Title="..." \ photo.jpg ```

7. Scripting Integration

7.1 Python Wrapper Pattern

```python import subprocess import os

def geotag_photos(photo_dir, gpx_file): """Geotag photos from GPX track file.""" for filename in os.listdir(photo_dir): if filename.lower().endswith(('.jpg', '.nef')): filepath = os.path.join(photo_dir, filename) subprocess.run([ 'exiftool', '-overwrite_original', '-geotag', gpx_file, filepath ], check=True)

def extract_for_database(photo_dir, output_csv): """Extract structured metadata for database import.""" subprocess.run([ 'exiftool', '-T', # Tab-separated '-filename', '-DateTimeOriginal', '-CreateDate', '-GPSLatitude', '-GPSLongitude', '-Make', '-Model', '-LensModel', '-ExposureTime', '-FNumber', '-ISO', '-r', # Recursive '-csv', f'>{output_csv}', photo_dir ], check=True) ```

7.2 Bash Functions for Common Tasks

```bash #!/bin/bash

exif-rename.sh - Rename files based on date taken

exiftool '-FileName

exif-compare.sh - Compare metadata between two files

compare_meta() { echo "=== File 1 ===" exiftool -s "$1" echo "=== File 2 ===" exiftool -s "$2" echo "=== Differences ===" diff <(exiftool -s "$1" | sort) <(exiftool -s "$2" | sort) } ```

8. Performance & Optimization

8.1 Fast Metadata Stripping

```bash

Remove metadata without re-encoding (fastest method)

exiftool -all= -overwrite_original *.jpg

UsingIgnoreMinorErrors for corrupted files

exiftool -ignoreMinorErrors -overwrite_original -all= bad_file.jpg

Parallel processing with progress

find . -name "*.jpg" -print0 | \ xargs -0 -P 8 -I {} exiftool -overwrite_original -all= {} ```

8.2 Incremental Updates

```bash

Only write if value differs (reduces file system writes)

exiftool -if 'not $Artist or $Artist ne "Name"' -Artist="Name" .

Use Phil Harvey's recommended write order for stability

XMP → EXIF → IPTC → PNG → JPEG → etc.

```

9. Troubleshooting Advanced Issues

IssueSolution
Write-protected filesUse -overwrite_original or remove write protection
Corrupted metadataAdd -ignoreMinorErrors flag
Unsynchronized sidecar filesUse -srcfile with -overwrite_original_in_place
Encoding problemsSpecify encoding: -charset UTF8 or -charset Latin1
Slow batch processingProcess smaller batches, use -progress to monitor

9.1 Recovery Commands

```bash

Restore from backup (ExifTool creates *_original files)

exiftool -restore_original image.jpg

Restore all originals in directory

exiftool -restore_original -r .

Verify metadata integrity

exiftool -validate -v image.jpg ```

10. Quick Reference Card

```bash

Read all

exiftool -a -s -G:1 file.jpg

Write single tag

exiftool -Tag="Value" file.jpg

Conditional write

exiftool -if '$condition' -Tag="Value" file.jpg

Batch recursive

exiftool -r -Tag="Value" /directory/

Strip all metadata

exiftool -all= -overwrite_original file.jpg

Geotag from GPX

exiftool -geotag track.gpx *.jpg

Date shift

exiftool -alldates+=1:00 file.jpg

Extract to CSV

exiftool -csv -filename -date* -gps* . > output.csv

Extract thumbnail

exiftool -b -ThumbnailImage photo.jpg > thumb.jpg

Create backup and overwrite

exiftool -overwrite_original -Tag="Value" file.jpg ```

Next Steps

ExifTool's power scales with your use case. Start with one advanced workflow—batch geotagging, privacy scrubbing, or Python integration—and build from there. Bookmark the official ExifTool documentation and tag name database as your constant references.

Try Calabi free at calabilabs.com — 10 cleans, no card.

10 free cleans. See the forensic proof before you download.
Try free →

Related