Write time information from the file name into the FileModifyDate

Started by mfk1955, December 02, 2022, 12:11:11 PM

Previous topic - Next topic

mfk1955

For some Videofiles I need to use a converter which deletes all time stamps from the orinal file and writes the date and time of the conversion into the system FileModifyDate field.
So far I can only preserve the original date (when the video was recorded) by batch renaming the files prior to the conversion.
The syntax of the files is then e.g. Sony C1234-2021-10-12 14-23-10.MP4.
Then I use Lossless Cut to extract part of the video file and the name becomes
Sony C1234-2021-10-12 14-23-10-00.00.00.000-00.00.13.286.mkv (if I cut out the first about 13 seconds)
(note that LLC cannot generate a MP4 file from the Sony Videoformat which I use, only mkv).

MKV cannot be used by Adobe Premiere so I need to convert MKV to MP4. All software I found deletes the timestamps during conversion, I am using VideoProc Converter.

After the conversion I have date and time of the conversion in the System FileModifyDate field and
0000:00:00 00:00:00 in the Quicktime date fields.
 
Is there a way to use 2021-10-12 14-23-10 from the file name (with that syntax, can't change it using : iso - ) and write it into one of the EXIF date fields ?

kind regards
Manfred

wywh

I'd recommend to rename all image and movie files by date to something like YYYY-MMDD-hhmm-ss.*

Then it is easy to set metadata dates by filename to newly encoded movies with:

exiftool -api QuickTimeUTC=1 '-AllDates<FileName' '-Track*Date<FileName' '-Media*Date<FileName' '-Keys:CreationDate<FileName' -execute '-FileCreateDate<FileName' '-FileModifyDate<FileName' -common_args -m -P -overwrite_original_in_place -wm w .
...or copy some 'Keys' from .mov to a same name .m4v in the same folder:

exiftool -m -P -overwrite_original_in_place -TagsFromFile '%-.0f.mov' -Keys:GPSCoordinates -Keys:Make -Keys:Model -Keys:Software *.m4v
...or copy date and some 'Keys' from .mov to a same name .m4v in the same folder:

exiftool -m -P -overwrite_original_in_place -TagsFromFile '%-.0f.mov' '-AllDates<QuickTime:CreateDate' '-Track*Date<QuickTime:CreateDate' '-Media*Date<QuickTime:CreateDate' -Keys:CreationDate -Keys:GPSCoordinates -Keys:Make -Keys:Model -Keys:Software *.m4v
...or copy all from .mov to a same name .m4v in the same folder and set file dates (all Track*Date, Media*Date, Keys might not be updated if they do not exist in the source):

exiftool -TagsFromFile '%-.0f.mov' -All:All *.m4v -execute '-FileCreateDate<QuickTime:CreateDate' '-FileModifyDate<QuickTime:CreateDate' -common_args -m -P -overwrite_original_in_place .
...or copy GPS from .jpg to a same name .mp4:

exiftool -m -P -overwrite_original_in_place -ext mp4 -TagsFromFile %d%f.jpg '-Keys:GPSCoordinates<$GPSLatitude, $GPSLongitude, $GPSAltitude' .
- Matti

mfk1955

Thank you very much for your reply. How would I specify in that syntax the folder name on which I want to apply that ?

mfk1955

#3
I tried the following but did not work. message "system can't find the specified file"

exiftool -api QuickTimeUTC=1 '-AllDates<FileName' '-Track*Date<FileName' '-Media*Date<FileName' '-Keys:CreationDate<FileName' -execute '-FileCreateDate<FileName' '-FileModifyDate<FileName' -common_args -m -P -overwrite_original_in_place -wm w "H:\Videos Hauptordner H\Testbereich"

Das System kann die angegebene Datei nicht finden

mfk1955

#4
tried it simpler but that also did not work (with different error message)

C:\Windows>exiftool ,,-AllDates<FileName" "H:\Videos Hauptordner H\Testbereich"
Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch.


Filenams were e.g. 2022-12-02 13-20-33.mp4

mfk1955

I found the issue with the syntax. It did not like the *,,* generated in word, has to be *"*

but I face another issue. My renamer uses the system FileModifyDate but that might have changed earlier (e.g. when I correct the time due to wrong camera time setting), hence I need to overwrite the system FileModifydate with Quicktime FileModifyDate before I use that to rename the file.
What would be the code for that ?

Phil Harvey

I think you may mean CreateDate and not QuickTime FileModifyDate.  This command will set the FileModifyDate from the QuickTime (or EXIF) CreateDate:

exiftool "-filemodifydate<createdate" DIR

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

StarGeek

Quote from: mfk1955 on December 02, 2022, 01:59:33 PM"H:\Videos Hauptordner H\Testbereich"

You appear to be using Windows.  Under CMD, you need to use double quotes instead of single quotes that wywh's example uses.  Under PowerShell, you would use the single quotes as shown.

Quote from: mfk1955 on December 02, 2022, 12:11:11 PMIs there a way to use 2021-10-12 14-23-10 from the file name (with that syntax, can't change it using : iso - )

I'm assuming that is YearMonthDayHourMinuteSecond.  If so, any date time tag you want to set can be copied directly from the filename. See FAQ #5, paragraph starting "Having said this"

Your command from post number 3 would work under CMD with the quote change.  The -execute option isn't needed.  The -P (-preserve) option isn't needed as you are changing the FileModifyDate anyway.  The -overwrite_original option should be used instead of the -overwrite_original_in_place option unless the file has XAttr/MDItem tags (Mac) or Alternate Data Streams (Windows) that need to be preserved.

exiftool -api QuickTimeUTC=1 "-AllDates<FileName" "-Track*Date<FileName" "-Media*Date<FileName" "-Keys:CreationDate<FileName" "-FileCreateDate<FileName" "-FileModifyDate<FileName" -P -overwrite_original "H:\Videos Hauptordner H\Testbereich"

Another thing to be aware of is that accented characters in the filename under Windows are problematic with the Perl Windows libraries that exiftool uses. You can see FAQ #18 for possible solutions.

One more thing to be aware of is that the Quicktime tags, except for DateTimeOriginal (part of the AllDates shortcut) and CreationDate, are supposed to be in UTC.  The -api QuickTimeUTC option used above will adjust the time stamps written to UTC based upon the local time zone.  Alterations would need to be made the files are in a different time zone.  And the -api QuickTimeUTC option would also need to be used to adjust the UTC time to the local time when you copy from one of the Quicktime tags.

* 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).

mfk1955


wywh

Quote from: StarGeek on December 03, 2022, 03:16:49 PMYour command from post number 3

> The -execute option isn't needed

I have tried it, but with macOS the FileCreateDate moves only backwards unless I make -execute command just for it.

Maybe this is related to the issue where macOS the asks for Xcode Command Line Tools install which can be ignored but then the FileCreateDate moves only backwards in time (the install is quite small and fast, not the huge Xcode install)?

> The -P (-preserve) option isn't needed as you are changing the FileModifyDate anyway

...I have -P as a placeholder because I usually want to preserve filedates. And even when I do want to change them it does not seem to interfere...

> The -overwrite_original option should be used instead of the -overwrite_original_in_place option unless the file has XAttr/MDItem tags (Mac) or Alternate Data Streams (Windows) that need to be preserved.

...I have used -overwrite_original_in_place to make sure every macOS attribute is preserved... ...hmm when do I have that kind of XAttr/MDItem tags??

- Matti

StarGeek

Quote from: wywh on December 08, 2022, 12:36:46 PM
Quote from: StarGeek on December 03, 2022, 03:16:49 PMYour command from post number 3

> The -execute option isn't needed

I have tried it, but with macOS the FileCreateDate moves only backwards unless I make -execute command just for it.

I wouldn't know about under MacOS, but @mfk1955 appears to be using Windows, due to the file path including H:\

Quote> The -P (-preserve) option isn't needed as you are changing the FileModifyDate anyway

...I have -P as a placeholder because I usually want to preserve filedates. And even when I do want to change them it does not seem to interfere...

Quite reasonable as that works for you. And you are probably correct that it won't interfere, though I haven't actually tested it on Windows. I was just pointing out that it isn't needed.  It would be up to @mfk1955 to decide if they wanted to use it.

QuoteThe -overwrite_original option should be used instead of the -overwrite_original_in_place option unless the file has XAttr/MDItem tags (Mac) or Alternate Data Streams (Windows) that need to be preserved.

...I have used -overwrite_original_in_place to make sure every macOS attribute is preserved... ...hmm when do I have that kind of XAttr/MDItem tags??

From what little I've read, it seems that Mac Finder is significantly better than the native Windows search, so it's quite reasonable to try and keep such data, even though the -overwrite_original_in_place option is slower.  On Windows, Alternate Data Streams are rare and are not standardized like XAttr/MDItem seems to be on Mac, so there really isn't a reason to use -overwrite_original_in_place.  There are only two times where I've seen legitimate (non-malicious) ADSs.  One is a digital comic book reader which uses them in the case of CDR (rar archives) since rar isn't open source code and it can't embed data like in a zip archive, and in Chromium based browsers (not sure about FireFox) which saves the url for downloaded files.
* 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).