Filling up DateTimeOriginal with FileModifyDate

Started by saurabh, January 14, 2015, 04:56:36 PM

Previous topic - Next topic

saurabh

Out of the thousands of JPEG files in my collection, some do not have any EXIF information. For these files, I would like to fill up the DateTimeOriginal EXIF field with FileModifyDate info from the OS. This lets me rename all files based on their DateTimeOriginal.

Can someone help with a command that lets me selectively run the command:

exiftool "-DateTimeOriginal<FileModifyDate" <filename>

on those files that do not have DateTimeOriginal populated already? Thanks!

StarGeek

Try this :
exiftool -if "not defined $DateTimeOriginal" "-DateTimeOriginal<FileModifyDate" <filename>

Test if first, of course, but it should work.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

saurabh

Your solution is so much better than mine. I wrote this highly inefficient script:

for file in `find -name *.jpeg`
do
   exiftool -time:all -s $file | grep DateTimeOriginal >/dev/null
   if [ $? != 0 ]
   then
      echo $file
      exiftool "-DateTimeOriginal<FileModifyDate" $file
   fi
done

I'll try yours and let you know if it works...

Phil Harvey

Also, you don't need to use "find" and loop over files.  See common mistake number 3.

- 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 ($).

saurabh

exiftool -if "not defined $DateTimeOriginal" "-DateTimeOriginal<FileModifyDate" <filename>

totally worked for me. And I learned some new things. Thanks.