我正在使用拖放功能將郵件從郵件中拖放到共享服務器上的相關作業子文件夾中。然後我使用一個腳本按照創建的日期進行排序(這是我將它們拖過的日期),然後根據它的容器名稱重命名該文件。使用蘋果腳本提取.eml文件發送的發件人和日期
但是我想用腳本從每個.eml文件中提取發送的日期,發件人和主題,然後使用該信息重命名文件。
有一個以前的帖子回答了類似的問題,但我不清楚(因爲我是一個腳本新手)如何將它放入我的腳本。 它可以發現: 「的AppleScript - 獲取.eml文件信息」
答案是:
set fromField to text 7 thru -1 of (do shell script "cat /test.eml | grep From:")
set dateField to text 7 thru -1 of (do shell script "cat test.eml | grep Date:")
set toField to text 5 thru -1 of (do shell script "cat /test.eml | grep To:")
set subjectField to text 10 thru -1 of (do shell script "cat /test.eml | grep Subject:")
我想我需要有人寫實際shell腳本,並告訴我在什麼地方它。
首先感謝您的幫助安裝Satimage Osax擴展。我嘗試了腳本,它正在獲取信息。然而,當我添加一行將aFile重命名爲newName時,它出現了堆棧溢出錯誤。還有一種方法可以將日期轉換爲ddmmyyyy格式? –
請參閱編輯日期格式。您需要操作newName以符合文件命名標準以避免錯誤。 – adayzdone
我收到一個Finder錯誤:無法在第一個修剪(mDate,7)處繼續修剪。如果我刪除所有修剪,它將重命名文件(大量文本),但主題丟失。所有你的幫助非常感謝 –