How can I randomize EXIF CreateDate across multiple JPGs within a known year using ExifTool?

Asked 7/30/2020

7 views

2 answers

0

I’ve scanned a batch of 6x4 print photos to JPG. I don’t know the exact capture dates, but for many of them I do know the year. I want to assign each file a randomized EXIF creation date somewhere within that specific year, ideally with a single ExifTool workflow for multiple files.

Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0

Photography Stack Exchange contributor

5y ago

2 Answers

2

The easiest way to do this would be to first set all files to the first second of the year you want to randomize
exiftool -CreateDate="1985:1:1 0:0:0" /path/to/files/

Then you could shift that time by a random number of days/hours/minutes/seconds like this
exiftool "-CreateDate+<${Filename;$_=int(rand(365)).' ' .int(rand(24)).':'.int(rand(60)).':'.int(rand(60))}" /path/to/files

Here, Filename is used as a placeholder to access exiftool's Advanced formatting feature, i.e. using direct Perl code, to get a random day, hour, minute and second to add to the base time.

This command creates backup files. Add -overwrite_original to suppress the creation of backup files. Add -r to recurse into subdirectories. If this command is run under Unix/Mac, reverse any double/single quotes to avoid bash interpretation.

See also: How can I incrementally date photos?

Originally by user37960. Source · Licensed CC BY-SA 4.0

user37960

5y ago

0

AI Answer

Generated from our catalog & community — verify before relying on it.

Yes. A simple approach is to first set every file to the start of the known year, then add a random offset.

Example:

  1. Set a base date: exiftool -CreateDate="1985:1:1 0:0:0" /path/to/files/

  2. Add a random day/hour/minute/second: exiftool "-CreateDate+<${Filename;$_=int(rand(365)).' '.int(rand(24)).':'.int(rand(60)).':'.int(rand(60))}" /path/to/files

This uses ExifTool’s advanced formatting to generate a random offset for each file. Filename is just a placeholder to trigger that formatting feature.

Notes:

  • ExifTool creates backup files by default; add -overwrite_original if you don’t want backups.
  • Add -r to process subfolders recursively.
  • On Unix/macOS shells, you may need to reverse the quote styles compared with the example, depending on your shell.

If needed, you can apply the same idea to other date tags as well, but the provided example specifically sets CreateDate.

UniqueBot

AI

5y ago

Your Answer