Author Topic: Time and date from CSV file  (Read 84 times)

ocelotgabs

  • Newbie
  • *
  • Posts: 5
Time and date from CSV file
« on: May 13, 2019, 09:12:18 PM »
Hello,

I have several scanned images from camera traps which used film (no digital). So I don't have the correct metadata from time and dates in the images. I however have them in a csv file. I need to import these correct time and dates to the images. Can I do that using exiftool? If so how? Thanks in advance !!!

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14425
    • ExifTool Home Page
Re: Time and date from CSV file
« Reply #1 on: May 13, 2019, 09:16:36 PM »
Yes.  FAQ 26 provides some help with this.

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

ocelotgabs

  • Newbie
  • *
  • Posts: 5
Re: Time and date from CSV file
« Reply #2 on: May 13, 2019, 09:17:37 PM »
Thanks Phil. I tried that and for some reason it didn't work.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14425
    • ExifTool Home Page
Re: Time and date from CSV file
« Reply #3 on: May 13, 2019, 09:18:23 PM »
Some details would be useful.  Could you post the command you used and attach the CSV file?

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

ocelotgabs

  • Newbie
  • *
  • Posts: 5
Re: Time and date from CSV file
« Reply #4 on: May 13, 2019, 11:16:50 PM »
My images and csv file are in different folders.

My .csv file only has two columns: SourceFile and datetime

This is how one row of the SourceFile (A2) looks like:
Station 01\D0001\007_rev1_0_no data_x.jpg

The datetime column looks like this (B2):
2008:01:25 19:54:00
*I have some empty rows in datetime

This is what I write in cmd

exiftool -datetime -csv G:\TEST_camtrapR\TestCamtrapR\data\testt
ime2.csv C:\Users\Bella\Pictures\CameraTraps\Project_GTM-005_Carmelita-AFISAP_20
08

What am I doing wrong?



StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2368
Re: Time and date from CSV file
« Reply #5 on: May 14, 2019, 12:49:15 AM »
Is the full path to your example file this?
C:\Users\Bella\Pictures\CameraTraps\Project_GTM-005_Carmelita-AFISAP_20\Station 01\D0001\007_rev1_0_no data_x.jpg

At the very least, you're not telling exiftool to check subdirectories.  You're only checking files in C:\Users\Bella\Pictures\CameraTraps\Project_GTM-005_Carmelita-AFISAP_20.  Add the -r option to check subdirectories.

But this won't be enough.  The file path you have in the csv will only be relative to the current directory.  You need to either add the full path to the SourceFile column, or CD into "C:\Users\Bella\Pictures\CameraTraps\Project_GTM-005_Carmelita-AFISAP_20" before running the command.

Finally, are you sure the tag you want to write to is DateTime?  That will write to the XMP-tiff:DateTime tag.  If you want to write to the EXIF block DateTime tag, which is that last time the image has been modified, then exiftool calls that ModifyDate.  If you want to write to the time the image was taken, then that would be DateTimeOriginal.  Or you could use AllDates which would write to DateTimeOriginal, ModifyDate (aka DateTime), and CreateDate (aka DateTimeDigitized).
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

ocelotgabs

  • Newbie
  • *
  • Posts: 5
Re: Time and date from CSV file
« Reply #6 on: May 14, 2019, 03:04:08 PM »
Thank you StarGeek!

Ok, so I modified the SourceFile for each row to include the full path:
C:\Users\Bella\Pictures\CameraTraps\Project_GTM-005_Carmelita-AFISAP_20\Station 01\D0001\007_rev1_0_no data_x.jpg

I renamed the second column (my csv only has two columns) as DateTimeOriginal

Then I opened cmd and typed this:

exiftool -DateTimeOriginal -csv -r "G:\TEST_camtrapR\TestCamtrapR\data\testtime2.csv" "C:\Users\Bella\Pictures\CameraTra
ps\Project_GTM-005_Carmelita-AFISAP_2008"

But when I check a picture that should have the original date modified it still has the old date (2018).

File Modification Date/Time     : 2019:05:14 13:35:57-05:00
File Access Date/Time           : 2019:05:14 13:35:57-05:00
File Creation Date/Time         : 2018:02:20 21:00:31-06:00

What am I doing wrong?
PS My csv has some date time cells blank because I don't want to modify all the pictures.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14425
    • ExifTool Home Page
Re: Time and date from CSV file
« Reply #7 on: May 14, 2019, 03:39:01 PM »
exiftool -DateTimeOriginal -csv -r "G:\TEST_camtrapR\TestCamtrapR\data\testtime2.csv" "C:\Users\Bella\Pictures\CameraTraps\Project_GTM-005_Carmelita-AFISAP_2008"

Try this:

exiftool -DateTimeOriginal -r -csv="G:\TEST_camtrapR\TestCamtrapR\data\testtime2.csv" "C:\Users\Bella\Pictures\CameraTraps\Project_GTM-005_Carmelita-AFISAP_2008"

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

ocelotgabs

  • Newbie
  • *
  • Posts: 5
Re: Time and date from CSV file
« Reply #8 on: May 22, 2019, 04:38:34 PM »
I just wanted to say that it worked! You guys are geniuses! Thanks for all the help.