使用 ExifTool 批量從檔案名添加 Exif 日期

淺羽的攝影工作流建立在 Adobe 全家桶上,並且固執地使用 Lightroom Classic CC。Lightroom 的自動匯出流程非常方便,可以匯出多種格式、自動重命名、添加水印並且去除照片資料;但問題在於它去除得太乾淨了,把包括拍攝日期在內的所有資料全部去除了,並且不能有選擇地保留。不過淺羽匯出的檔案名包括了拍攝時間日期,於是可以使用開源免費的 ExifTool 重新處理一下檔案。

ExifTool 是一個 Perl 庫外加 CLI 工具,可以支援多種檔案的 Exif 資料,參數靈活強大。淺羽通常會匯出 JPEG 格式檔案,名字如 SKG-20190426-164737.jpg,所以指定一下檔案名格式就可以直接處理好。

$ exiftool -d SKG-%Y%m%d-%H%M%S.jpg "-alldates<filename" "-filemodifydate<datetimeoriginal#" -ext jpg .
======== ./SKG-20190426-145918.jpg
======== ./SKG-20190426-152009.jpg
======== ./SKG-20190426-152014.jpg
======== ./SKG-20190426-152028.jpg
======== ./SKG-20190426-152035.jpg
======== ./SKG-20190426-152037.jpg
======== ./SKG-20190426-152142.jpg
======== ./SKG-20190426-152147.jpg
======== ./SKG-20190426-153154.jpg
======== ./SKG-20190426-153448.jpg
======== ./SKG-20190426-153451.jpg
======== ./SKG-20190426-163712.jpg
======== ./SKG-20190426-163957.jpg
======== ./SKG-20190426-164737.jpg
======== ./SKG-20190426-164819.jpg
======== ./SKG-20190426-165327.jpg
======== ./SKG-20190426-152014.jpg
    1 directories scanned
   17 image files updated
<-END-

由於沒有指定改名、複製動作,所以 ExifTool 會直接操作源圖片,添加 DateTimeOriginalCreateTime 字段資料。現在查看照片就有拍攝時間日期了,並且上載到 Google Photos 也能正確識別。

另外,ExifTool 的參數功能很強大,作者也認爲「如果需要配合其他工具使用,往往是因爲用家沒有仔細讀文檔」。不過,讀文檔的時間好像已經夠寫一個小 Script 了?

來自作者的溫馨小提示

Comments

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

To respond on your own website, enter the URL of your response which should contain a link to this post’s permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post’s URL again. (Find out more about Webmentions.)