0

I've been wrangling nearly 40TBs of videos that were recovered from 2 crashed RAIDs. Nearly all files have correct EncodeDate, TrackCreateDate and/or MediaCreateDate, but I'm biff'd on a mass rename using the wrong EXIF commands and ended up with files names, FileModifyDates and CreateDates...

Bummer, yes.

I essentially want to run a recursive command that will run through the assets pulling the oldest date & time from all the available tags and then either set the FileModify or CreateDate OR at very least just update the filename.

I can get to my wanted net result through either of those results.

I've found several posts pertaining to image files for something like this, but not video files. Though I do know and use Exiftool daily to modify video assets.

When trying to run the script below or botched versions I've tried to create (have zero scripting knowledge and have been trying to learn) no matter what I cannot get it to pull the oldest and apply it to all other tags.

# remove all Umlaute
exiftool -L -overwrite_original -api "Filter=s/ä/ae/g;s/ö/oe/g;s/ü/ue/g;s/Ä/Ae/g;s/Ö/Oe/g;s/Ü/Ue/g;s/ß/ss/g" -TagsFromFile @ -all:all .


# add ", " to the caption:

exiftool '-caption-abstract<${caption-abstract}, ' .

# set all dates to the earliest date
set earliest_date="`exiftool -CreateDate -fileorder CreateDate -q -s3 . | head -1`"
set latest_date="`exiftool -CreateDate -fileorder -CreateDate -q -s3 . | tail -1`"

if ( "$earliest_date" == "$latest_date" ) then
   echo "checked date"
else
   echo "earliest date is $earliest_date and latest date is $latest_date"
   echo "setting -CreateDate to $earliest_date and TimeCreated to unknown"
   exiftool -CreateDate=$earliest_date .
   exiftool -TimeCreated="00:00:00" .
endif

My test was very simple. Manually modify the TrackCreate date to a noticeable different date and run the script. Below is the result from the terminal.

[HEATHEN-Mac-Pro:> LANDSCAPE/untitled folder copy/untitled folder copy] heathenadmin% #!/bin/tcsh -f
/bin/tcsh: Event not found.


# remove all Umlaute
exiftool -L -overwrite_original -api "Filter=s/ä/ae/g;s/ö/oe/g;s/ü/ue/g;s/Ä/Ae/g;s/Ö/Oe/g;s/Ü/Ue/g;s/ß/ss/g" -TagsFromFile @ -all:all .


# add ", " to the caption:

exiftool '-caption-abstract<${caption-abstract}, ' .

# set all dates to the earliest date
set earliest_date="`exiftool -CreateDate -fileorder CreateDate -q -s3 . | head -1`"
set latest_date="`exiftool -CreateDate -fileorder -CreateDate -q -s3 . | tail -1`"

if ( "$earliest_date" == "$latest_date" ) then
   echo "checked date"
else
   echo "earliest date is $earliest_date and latest date is $latest_date"
   echo "setting -CreateDate to $earliest_date and TimeCreated to unknown"
   exiftool -CreateDate=$earliest_date .
   exiftool -TimeCreated="00:00:00" .
endif[HEATHEN-Mac-Pro:> LANDSCAPE/untitled folder copy/untitled folder copy] heathenadmin% 
[HEATHEN-Mac-Pro:> LANDSCAPE/untitled folder copy/untitled folder copy] heathenadmin% 
[HEATHEN-Mac-Pro:> LANDSCAPE/untitled folder copy/untitled folder copy] heathenadmin% # remove all Umlaute
#: Command not found.
[HEATHEN-Mac-Pro:> LANDSCAPE/untitled folder copy/untitled folder copy] heathenadmin% exiftool -L -overwrite_original -api "Filter=s/ä/ae/g;s/ö/oe/g;s/ü/ue/g;s/Ä/Ae/g;s/Ö/Oe/g;s/Ü/Ue/g;s/ß/ss/g" -TagsFromFile @ -all:all .
    1 directories scanned
    1 image files updated
[HEATHEN-Mac-Pro:> LANDSCAPE/untitled folder copy/untitled folder copy] heathenadmin% 
[HEATHEN-Mac-Pro:> LANDSCAPE/untitled folder copy/untitled folder copy] heathenadmin% 
[HEATHEN-Mac-Pro:> LANDSCAPE/untitled folder copy/untitled folder copy] heathenadmin% # add ", " to the caption:
#: Command not found.
[HEATHEN-Mac-Pro:> LANDSCAPE/untitled folder copy/untitled folder copy] heathenadmin% 
[HEATHEN-Mac-Pro:> LANDSCAPE/untitled folder copy/untitled folder copy] heathenadmin% exiftool '-caption-abstract<${caption-abstract}, ' .
Warning: [minor] Tag 'caption-abstract' not defined - ./2007-01-12-09-14-28-HEATHEN-2k-RAW.mp4
Warning: No writable tags set from ./2007-01-12-09-14-28-HEATHEN-2k-RAW.mp4
    1 directories scanned
    0 image files updated
    1 image files unchanged
[HEATHEN-Mac-Pro:> LANDSCAPE/untitled folder copy/untitled folder copy] heathenadmin% 
[HEATHEN-Mac-Pro:> LANDSCAPE/untitled folder copy/untitled folder copy] heathenadmin% # set all dates to the earliest date
#: Command not found.
[HEATHEN-Mac-Pro:> LANDSCAPE/untitled folder copy/untitled folder copy] heathenadmin% set earliest_date="`exiftool -CreateDate -fileorder CreateDate -q -s3 . | head -1`"
[HEATHEN-Mac-Pro:> LANDSCAPE/untitled folder copy/untitled folder copy] heathenadmin% set latest_date="`exiftool -CreateDate -fileorder -CreateDate -q -s3 . | tail -1`"
[HEATHEN-Mac-Pro:> LANDSCAPE/untitled folder copy/untitled folder copy] heathenadmin% 
[HEATHEN-Mac-Pro:> LANDSCAPE/untitled folder copy/untitled folder copy] heathenadmin% if ( "$earliest_date" == "$latest_date" ) then
[HEATHEN-Mac-Pro:> LANDSCAPE/untitled folder copy/untitled folder copy] heathenadmin%    echo "checked date"
checked date
[HEATHEN-Mac-Pro:> LANDSCAPE/untitled folder copy/untitled folder copy] heathenadmin% else
else?    echo "earliest date is $earliest_date and latest date is $latest_date"
else?    echo "setting -CreateDate to $earliest_date and TimeCreated to unknown"
else?    exiftool -CreateDate=$earliest_date .
else?    exiftool -TimeCreated="00:00:00" .
else? endif

And here is the EXIF date on the test file.

======== /Volumes/Scratch SSD/> DUPE SCAN/DROPBOX Restore/> LANDSCAPE/untitled folder copy/untitled folder copy/2007-01-12-09-14-28-HEATHEN-2k-RAW.mp4
ExifToolVersion                 : 12.00
FileName                        : 2007-01-12-09-14-28-HEATHEN-2k-RAW.mp4
Directory                       : /Volumes/Scratch SSD/> DUPE SCAN/DROPBOX Restore/> LANDSCAPE/untitled folder copy/untitled folder copy
FileSize                        : 391 MB
FileModifyDate                  : 2020:12:01 23:49:50-05:00
FileAccessDate                  : 2020:12:01 23:50:13-05:00
FileInodeChangeDate             : 2020:12:01 23:49:50-05:00
FilePermissions                 : rwx------
FileType                        : MP4
FileTypeExtension               : mp4
MIMEType                        : video/mp4
MajorBrand                      : MP4  Base Media v1 [IS0 14496-12:2003]
MinorVersion                    : 0.2.0
CompatibleBrands                : isom, iso2, mp41
MovieHeaderVersion              : 0
CreateDate                      : 2008:01:12 09:14:28
ModifyDate                      : 2008:01:12 09:14:28
TimeScale                       : 1000
Duration                        : 0:09:54
PreferredRate                   : 1
PreferredVolume                 : 100.00%
PreviewTime                     : 0 s
PreviewDuration                 : 0 s
PosterTime                      : 0 s
SelectionTime                   : 0 s
SelectionDuration               : 0 s
CurrentTime                     : 0 s
NextTrackID                     : 3
TrackHeaderVersion              : 0
TrackCreateDate                 : 2007:01:12 09:14:28
TrackModifyDate                 : 2008:01:12 09:14:28
TrackID                         : 1
TrackDuration                   : 0:09:54
TrackLayer                      : 0
TrackVolume                     : 0.00%
ImageWidth                      : 2048
ImageHeight                     : 1152
GraphicsMode                    : srcCopy
OpColor                         : 0 0 0
CompressorID                    : hvc1
SourceImageWidth                : 2048
SourceImageHeight               : 1152
XResolution                     : 72
YResolution                     : 72
BitDepth                        : 24
VideoFieldOrder                 : Progressive; 0
PixelAspectRatio                : 1:1
VideoFrameRate                  : 29.97
MatrixStructure                 : 1 0 0 0 1 0 0 0 1
MediaHeaderVersion              : 0
MediaCreateDate                 : 2008:01:12 09:14:28
MediaModifyDate                 : 2008:01:12 09:14:28
MediaTimeScale                  : 48000
MediaDuration                   : 0:09:54
MediaLanguageCode               : eng
HandlerDescription              : Ambarella AAC
Balance                         : 0
AudioFormat                     : mp4a
AudioChannels                   : 2
AudioBitsPerSample              : 16
AudioSampleRate                 : 48000
HandlerType                     : Metadata
HandlerVendorID                 : Apple
Encoder                         : Lavf58.41.100
MediaDataSize                   : 409939927
MediaDataOffset                 : 513008
ImageSize                       : 2048x1152
Megapixels                      : 2.4
AvgBitrate                      : 5.52 Mbps
Rotation                        : 0

If anyone can provide any insight it would be a massive help to not pulling the rest of my hair out..

1
  • The easiest solution would be to use a user defined tag. Take a look at this thread for an example. The only thing to watch for is when the video date is set to 0000:00:00 00:00:00.
    – StarGeek
    Dec 19, 2020 at 17:30

1 Answer 1

0

You may want to look at the Advanced Renamer scripting utility. It’s free with a request for a modest donation.

www.advancedRenamer.com

It is extremely powerful at renaming / copying / moving both folders and files based on almost any criteria - including exif metadata.

I have used it to rename thousands of folders and files in just a few minutes.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .