EXIFTOOL 将 MP4 设置为最早日期递归 - 可以做到吗?

EXIFTOOL 将 MP4 设置为最早日期递归 - 可以做到吗?

我一直在处理从 2 个崩溃的 RAID 中恢复的近 40TB 视频。几乎所有文件都有正确的 EncodeDate、TrackCreateDate 和/或 MediaCreateDate,但我使用错误的 EXIF 命令进行批量重命名,结果文件名变成了 FileModifyDates 和 CreateDates...

真是倒霉,是的。

我本质上想要运行一个递归命令,该命令将遍历资产,从所有可用标签中提取最旧的日期和时间,然后设置 FileModify 或 CreateDate,或者至少只更新文件名。

我可以通过其中任一结果获得我想要的最终结果。

我发现有几篇帖子与此类图像文件有关,但与视频文件无关。不过我确实知道并每天使用 Exiftool 来修改视频资产。

当尝试运行下面的脚本或我尝试创建的拙劣版本(没有任何脚本知识并一直在尝试学习)时,无论如何我都无法让它拉出最旧的脚本并将其应用于所有其他标签。

# 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

我的测试很简单。手动将 TrackCreate 日期修改为明显不同的日期并运行脚本。以下是终端的结果。

[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

这是测试文件的 EXIF 日期。

======== /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

如果有人能提供任何见解,那将会对我避免拔掉剩下的头发有很大帮助。

答案1

您可能想看看 Advanced Renamer 脚本实用程序。它是免费的,但需要少量捐款。

www.advancedRenamer.com

它能够根据几乎任何标准(包括 exif 元数据)重命名/复制/移动文件夹和文件,功能极其强大。

我用它在短短几分钟内重命名了数千个文件夹和文件。

相关内容