Add/Update Missing/Incorrect datetimeoriginal from Date in Folder Name

Started by millerstevew, July 31, 2013, 07:53:52 PM

Previous topic - Next topic

millerstevew

I'm attempting to add the correct datetimeoriginal and datecreated to a number of old jpg files. I imagine this project will require two different steps (1) identifying images with missing or incorrect datetimeoriginal/datecreated and (2) adding or updating the datetimeoriginal/datecreated.

Note: My files are organized into subfolders by decade, year, and event. For example a graduation photo taken at a graduation taken on 5/17/2013 is located in "~/Pictures/2010 - 2020/2013/2013.05.17 - Graduation/DSC1000.jpg". For events spanning several days, like a vacation, the subfolder would be "~/Pictures/2010 - 2020/2013.06.20 - 2013.06.27 - Vacation/DSC2000.jpg".

Identifying:

Some of my files are missing EXIF data. What command would I use to find files with missing EXIF data? I would love to export this information to a text file.

Some files just have the wrong datetimeoriginal and datecreated. Can I use ExifTool to find files where the datetimeoriginal of the file differs from the date of the folder which contains it? If so, what command would I use to do this? Likewise, I would love to export this information to a text file.

Adding/Updating:

Once I identify files with missing or incorrect datetimeoriginal, can I use ExifTool to add this information from the date of the folder which contains it, given my specific folder structure? If so, what command would I use to do this? (I know that it is possible to add datetimeoriginal from the filename https://exiftool.org/forum/index.php?topic=4785.0 and folder name https://exiftool.org/forum/index.php?topic=3807.0.)


Thanks,
Steve

Phil Harvey

Hi Steve,

Quote from: millerstevew on July 31, 2013, 07:53:52 PM
What command would I use to find files with missing EXIF data?

exiftool -if "not $exif:all" ...

(the quoting above is for Windows, use single quotes instead on Mac/Linux)

QuoteI would love to export this information to a text file.

... > out.txt

QuoteSome files just have the wrong datetimeoriginal and datecreated. Can I use ExifTool to find files where the datetimeoriginal of the file differs from the date of the folder which contains it?

Tricky, but possible:

exiftool -if "$datetimeoriginal=~s/ .*// and $datetimeoriginal=~tr/:/./ and $directory!~/$datetimeoriginal/" ...

QuoteOnce I identify files with missing or incorrect datetimeoriginal, can I use ExifTool to add this information from the date of the folder which contains it, given my specific folder structure?

Again, tricky but possible:

exiftool "-datetimeoriginal<${directory;/(\d{4}).(\d{2}).(\d{2})/ ? $_=qq($1:$2:$3 00:00:00) : undef}" FILE

where FILE is one or more file and/or directory names.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

millerstevew

Phil,

Thanks for the quick response. I'm trying to troubleshoot what you've suggested. Note: I'm using a mac. When I do:

exiftool -if 'not $exif:all' ~/Pictures/1980\ -\ 1989/ -r > ~/Desktop/out.txt

I get a text file with the following contents:

   20 directories scanned
   18 files failed condition
    0 image files read


What I'm looking for is a list of the JPG files that fail the condition so that I might add EXIF data and a the correct datetimeoriginal. Is it possible to output a text file that includes a list of files with missing EXIF data?

Moreover, when I do:

exiftool -if '$datetimeoriginal=~s/ .*// and $datetimeoriginal=~tr/:/./ and $directory!~/$datetimeoriginal/' ~/Pictures/1980\ -\ 1989/ -r > ~/Desktop/out.txt

I get a text file with all the pictures that don't meet the conditions. However, this text file includes all of the EXIF data for each of these pictures. For example:

======== /Users/steve/Pictures/1980 - 1989/1987/1987.08.00 - Stevie in the Kitchen/001.jpg
ExifTool Version Number         : 9.34
File Name                       : 001.jpg
Directory                       : /Users/steve/Pictures/1980 - 1989/1987/1987.08.00 - Stevie in the Kitchen
File Size                       : 1018 kB
File Modification Date/Time     : 2010:03:01 21:40:06-06:00
File Access Date/Time           : 2013:08:07 22:05:53-05:00
File Inode Change Date/Time     : 2013:04:20 13:43:27-05:00
File Permissions                : rwxr-xr-x
File Type                       : JPEG
MIME Type                       : image/jpeg
JFIF Version                    : 1.01
Resolution Unit                 : inches
X Resolution                    : 600
Y Resolution                    : 600
Exif Byte Order                 : Big-endian (Motorola, MM)
Orientation                     : Horizontal (normal)
Software                        : Microsoft Windows Live Photo Gallery14.0.8081.709
Modify Date                     : 2009:11:15 14:19:15
Date/Time Original              : 1987:08:01 14:19:16
Create Date                     : 1987:08:01 14:19:16
Sub Sec Time Original           : 00
Sub Sec Time Digitized          : 00
Image Unique ID                 : F202EDFA7C26449E8EAEB22FB7656F66
Padding                         : (Binary data 1926 bytes, use -b option to extract)
Padding                         : (Binary data 2060 bytes, use -b option to extract)
About                           : uuid:faf5bdd5-ba3d-11da-ad31-d33d75182f1b
Date Acquired                   : 2009:11:15 20:17:05Z
Creator Tool                    : Microsoft Windows Live Photo Gallery14.0.8081.709
Creatortool                     : Microsoft Windows Live Photo Gallery14.0.8081.709
Create Date                     : 1987:08:01 14:19:16
Software                        : Microsoft Windows Live Photo Gallery14.0.8081.709
Software                        : Microsoft Windows Live Photo Gallery14.0.8081.709
Orientation                     : Horizontal (normal)
Image Unique ID                 : F202EDFA7C26449E8EAEB22FB7656F66
Image Width                     : 2987
Image Height                    : 2061
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Image Size                      : 2987x2061
Create Date                     : 1987:08:01 14:19:16.00
Date/Time Original              : 1987:08:01 14:19:16.00


(I understand that the above file is bound to fail because the folder's date is on the 0th of the month. This is my way of acknowledging that I do not know what date the photo was taken.)

That said, is it possible to output a text file that includes a simplified list of files with incorrect datetimeoriginal and perhaps their datetimeoriginal? (I understand this functionality may simply not exist.)

Thanks again. I love your tool!

- Steve

Phil Harvey

Hi Steve,

Quote from: millerstevew on August 07, 2013, 11:20:54 PM
exiftool -if 'not $exif:all' ~/Pictures/1980\ -\ 1989/ -r > ~/Desktop/out.txt

I get a text file with the following contents:

   20 directories scanned
   18 files failed condition
    0 image files read

This means that all of the 18 files contained some EXIF.

QuoteWhat I'm looking for is a list of the JPG files that fail the condition so that I might add EXIF data and a the correct datetimeoriginal. Is it possible to output a text file that includes a list of files with missing EXIF data?

You can do whatever you want with the files.  To just see the directory and file names, you could do this:

exiftool -if 'not $exif:all' ~/Pictures/1980\ -\ 1989/ -r -p '$directory/$filename' > ~/Desktop/out.txt

QuoteMoreover, when I do:

exiftool -if '$datetimeoriginal=~s/ .*// and $datetimeoriginal=~tr/:/./ and $directory!~/$datetimeoriginal/' ~/Pictures/1980\ -\ 1989/ -r > ~/Desktop/out.txt

I get a text file with all the pictures that don't meet the conditions.

Funny, I'm on a Mac and I just tried this and it works for me:

> exiftool -if '$datetimeoriginal=~s/ .*// and $datetimeoriginal=~tr/:/./ and $dictory!~/$datetimeoriginal/' ~/Pictures/Digital\ Pictures\ \(2013\)/ -r -datetimeoriginal -directory -filename -T
2013:02:15 12:10:20 /Users/phil/Pictures/Digital Pictures (2013)/2013-02-14 Resurfacer DSC01139.JPG
2013:02:15 12:11:37 /Users/phil/Pictures/Digital Pictures (2013)/2013-02-14 Resurfacer DSC01140.JPG
2013:03:15 14:47:12 /Users/phil/Pictures/Digital Pictures (2013)/2013-03-14 New K-01 IMGP0007.JPG
2013:03:15 14:47:31 /Users/phil/Pictures/Digital Pictures (2013)/2013-03-14 New K-01 IMGP0008.JPG
...


and otherwise the same command but with the inverse condition (files that do contain the date in the directory name):

> exiftool -if '$datetimeoriginal=~s/ .*// and $datetimeoriginal=~tr/:/./ and $directory=~/$datetimeoriginal/' ~/Pictures/Digital\ Pictures\ \(2013\)/ -r -datetimeoriginal -directory -filename -T
2013:01:01 11:58:01 /Users/phil/Pictures/Digital Pictures (2013)/2013-01-01 Frontenac Park DSC00979.JPG
2013:01:01 12:21:37 /Users/phil/Pictures/Digital Pictures (2013)/2013-01-01 Frontenac Park DSC00980.JPG
2013:01:01 12:21:54 /Users/phil/Pictures/Digital Pictures (2013)/2013-01-01 Frontenac Park DSC00981.JPG
2013:01:01 12:22:11 /Users/phil/Pictures/Digital Pictures (2013)/2013-01-01 Frontenac Park DSC00982.JPG
...


QuoteHowever, this text file includes all of the EXIF data for each of these pictures.

Yes.  ExifTool extracts all metadata if you don't give it something else to do.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

gagadada

Hi,

I've tried to follow this post, but it seems I'm too stupid to get it to work. Could you help me out here?

>C:\Desktop\exiftool-9.39\exiftool.exe -if "not $exif:all" c:\Desktop\picture\ -r -filename > c:\Desktop\out.txt

I get:

Quote1 directories scanned
    1 files failed condition
    0 image files read

But no filename list. If I leave "not $exif:all" away, I get the filename list, though.

What am I missing here?

Phil Harvey

With this -if option, a file will fail the condition if it contains EXIF.  The command you used only lists files that do not have EXIF.  If the list is empty, then all of the files contained EXIF.

I hope this makes sense.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

gagadada