ExifTool Forum

General => Metadata => Topic started by: ayanm00 on June 07, 2017, 10:37:33 PM

Title: Make Exif Date The File Name
Post by: ayanm00 on June 07, 2017, 10:37:33 PM
Hi,
I am importing all of my old digital videos to the Apple Photos app on my Mac. This app does not accept the MOD file format from my old Panasonic Digital Camcorder so I converted all 267 files to MP4.  Unfortunately, MOD is such a weird format that the metadata dates were not moved over. I've even tried multiple converting applications, but they have all given me the same issue. Fortunately, though, I named each file like this: 2017-06-07 09.30.00 AM or like this: 2017-06-07 09-30-00 AM so I still know exactly when each video was taken.

All the MP4 files still have their respective filenames from when they were MOD files, but they are just missing the metadata. Is there a way to use ExifTool to make the Metadata Date Modified, Date Taken, and Date Created the date from the file name? Also, is there a way to bulk rename all 267 files so that I don't have to go through and type in each individual directory?



Thank You So Much,
ayanm00
Title: Re: Make Exif Date The File Name
Post by: Hayo Baan on June 08, 2017, 01:45:58 AM
Have you already tried this:exiftool '-DateTimeOriginal<FileName' FILE
That will copy the date from the filename into the datetimeoriginal tag of the file FILE. Exiftool should be smart enough to figure out the date from the filename.
If this works, batch processing is easy: just replace FILE with -r -ext MP4 DIR where DIR is the root directory of where your files are.

Note: always try out these commands on a copy of a file first.
Note: actually exiftool will create a copy of the original itself and name it with a _original suffix. If you don't want/need that add the option -overwrite_original to the exiftool command.

Edit: corrected typo
Title: Re: Make Exif Date The File Name
Post by: StarGeek on June 08, 2017, 02:24:44 AM
I would suggest setting ModifyDate and CreateDate timestamps for mp4s, as those are more likely to be read by most software.
Title: Re: Make Exif Date The File Name
Post by: Hayo Baan on June 08, 2017, 02:41:46 AM
Quote from: StarGeek on June 08, 2017, 02:24:44 AM
I would suggest setting ModifyDate and CreateDate timestamps for mp4s, as those are more likely to be read by most software.
Ah yes, you are right!
So instead, the command should be something like
exiftool '-CreateDate<FileName' '-ModifyDate<FileName' FILE
and after you've tested this works, you can use the following to change all your mp4 files:
exiftool '-CreateDate<FileName' '-ModifyDate<FileName' -r -overwrite_original -ext MP4 DIR
where DIR is the root directory where you have placed your files.
Title: Re: Make Exif Date The File Name
Post by: ayanm00 on June 09, 2017, 12:36:07 AM
Thank you all so much for your help, but I'm still having an issue. After running the command above, the dates and times that are added are incorrect. For example, a file titled 2011-06-02 08.40.36 AM.mp4 is getting the time of June 2, 2011 3:40:36 AM, whereas it should be getting the time of June 2, 2011 8:40:36 AM, and another file titled 2011-12-25 01.50.06 PM.mp4 is getting the time of December 24, 2011 7:50:06 PM, whereas it should be getting the time of December 25, 2011 1:50:06 PM. How do I fix this?



Thank You,
ayanm00
Title: Re: Make Exif Date The File Name
Post by: Hayo Baan on June 09, 2017, 02:32:15 AM
Where are you seeing these dates? Not in exitftool, I reckon? Anyway, the problem is very likely that the application you used adheres the standard of using these times as UTC instead of local. Exiftool on the other hand defaults to local time here since most (?) cameras seem to use this non standard interpretation. To change this behaviour, add the option -api QuickTimeUTC to the command:exiftool -api QuickTimeUTC '-CreateDate<FileName' '-ModifyDate<FileName' FILE
Title: Re: Make Exif Date The File Name
Post by: ayanm00 on June 09, 2017, 02:44:22 AM
Hi again,
I'm seeing these dates in the Apple Photos app on my Mac, which is where I'm importing the videos to. Let me try adding that to the command and I'll get back to you.



Thank You,
ayanm00
Title: Re: Make Exif Date The File Name
Post by: ayanm00 on June 09, 2017, 02:49:57 AM
Yeah so I just checked the new command and AM videos are doing just fine but PM videos are being changed to AM in the Photos app. I'm in Central Standard Time in the United States, if that helps. How do I fix this?



Thanks,
ayanm00
Title: Re: Make Exif Date The File Name
Post by: Phil Harvey on June 09, 2017, 05:56:38 AM
Try doing this after the other command:

exiftool -createdate+=12 -modifydate+=12 -if "$filename =~ /PM/" DIR

- Phil
Title: Re: Make Exif Date The File Name
Post by: ayanm00 on June 09, 2017, 05:02:51 PM
Hi Phil,
the second command results in the response, "1 files failed condition," even after I tried multiple files with PM in them. Upon importing them to the Photos app, I can see that the PM dates still say AM.



Thanks,
ayanm00
Title: Re: Make Exif Date The File Name
Post by: StarGeek on June 09, 2017, 05:35:21 PM
Do the filenames have uppercase PM or are they mixed or lower case pm/Pm?  If it's the later case, change /PM/ to /PM/i.
Title: Re: Make Exif Date The File Name
Post by: ayanm00 on June 09, 2017, 10:15:32 PM
No, they are all uppercase PM.


Thanks,
ayanm00
Title: Re: Make Exif Date The File Name
Post by: Phil Harvey on June 10, 2017, 07:06:38 AM
You're on a Mac, so you need to use single quotes instead of double quotes.

- Phil
Title: Re: Make Exif Date The File Name
Post by: ayanm00 on June 10, 2017, 03:11:05 PM
Hi again,
Thank you all so much for helping me solve my Photos crisis! One last question: Is there a way to unify this all into one command for multiple files? It would be helpful if I could just specify the folder that the videos are located in so that I don't have to go through and drag in all the videos. Is it just putting all the commands into one line and adding -r -ext MP4 DIR to the end?



Thanks,
ayanm00
Title: Re: Make Exif Date The File Name
Post by: StarGeek on June 10, 2017, 04:20:37 PM
Quote from: ayanm00 on June 10, 2017, 03:11:05 PMIs it just putting all the commands into one line and adding -r -ext MP4 DIR to the end?

Almost, but not quite.  It's still going to take two passes so it can deal with the PM files, but it can be just one line
exiftool -api QuickTimeUTC '-CreateDate<FileName' '-ModifyDate<FileName' -execute -createdate+=12 -modifydate+=12 -if '$filename =~ /PM/' -common_args -ext MP4 -r DIR

Replace DIR with the actual directory path.
Title: Re: Make Exif Date The File Name
Post by: ayanm00 on June 11, 2017, 11:44:41 PM
Thank you all so much for your help! All my digital photos and videos are now on iCloud, and available on all of my devices! I could never have done it without you... well, I could have, but it would involve me manually tagging all of the photos and videos individually. Anyways, on to my next project: scanning and tagging all 20,000 of my analog photos. Any chance you guys have a robot that can do that for me? :)




Thank You,
ayanm00