Nach ein wenig weiterer Recherche hat sich mir dann folgendes Skript aufgetan:
Code:
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
-- Lege hier den Zielordner fest
set destFolder to "macOS:Users:usw.usw:"
tell application "Mail"
repeat with oneMessage in theMessages
set x to 1
set theSubject to subject of oneMessage
tell me
set theSubject to do shell script "echo " & theSubject & " | sed 's/:/–/g'"
end tell
repeat with oneAttachment in mail attachments of oneMessage
tell me
set _exists to true
repeat until _exists is false
try
alias (destFolder & theSubject & "_" & x & ".pdf")
set x to x + 1
on error
set _exists to false
end try
end repeat
end tell
set theName to theSubject & "_" & x & ".pdf"
save oneAttachment in file (destFolder & theName)
end repeat
end repeat
end tell
end perform mail action with messages
end using terms from
Das klappt einwandfrei und benennt sogar die Datei im Downloads Ordner nach dem Namen der E-mail