- Registriert
- 21.01.14
- Beiträge
- 2
Hallo,
ich möchte mit einem Apple Script meine Dateianhänge in Mail in verschiedene Unterordner speichern lassen.
Diese Unterordner sollen automatisch nach Dateiendungen benannt werden.
Ich schaffe es aber nicht den Unterordner nach der Dateiendung zu benennen.
Hat hier jemand Rat ?
Vielen Dank schon mal.
hier mein Ansatz:
using terms from application "Mail"
on perform mail action with messagestheMessagesfor ruletheRule
tell application "Finder"
set folderName to "Downloads"
set homePath to (path to home folder as text) as text
set attachmentsFolder to (homePath & folderName) as text
end tell
tell application "Mail"
repeat with eachMessage in theMessages
set attachCount to count of (mail attachments of eachMessage)
(* !!! Hier komme ich nicht weiter !!!*)
(* Es soll ein Unterordner erstellt werden, der den Namen der Dateiendung trägt*)
set subFolder to ("Attachment_extension")
if attachCount is not equal to 0 then
-- use the unix /bin/test command to test if the timeStamp folder exists. if not then create it and any intermediate directories as required
if (do shell script "/bin/test -e " & quoted form of ((POSIX path of attachmentsFolder) & "/" & subFolder) & " ; echo $?") is "1" then
-- 1 is false
do shell script "/bin/mkdir -p " & quoted form of ((POSIX path of attachmentsFolder) & "/" & subFolder)
end if
try
repeat with theAttachment in eachMessage'smail attachments
set originalName to name of theAttachment
set savePath to attachmentsFolder & ":" & subFolder & ":" & originalName
try
savetheAttachmentinfile (savePath)
end try
end repeat
end try
end if
end repeat
end tell
end perform mail action with messages
end using terms from
on pad(n)
return text -2 thru -1 of ("0" & n)
end pad
ich möchte mit einem Apple Script meine Dateianhänge in Mail in verschiedene Unterordner speichern lassen.
Diese Unterordner sollen automatisch nach Dateiendungen benannt werden.
Ich schaffe es aber nicht den Unterordner nach der Dateiendung zu benennen.
Hat hier jemand Rat ?
Vielen Dank schon mal.
hier mein Ansatz:
using terms from application "Mail"
on perform mail action with messagestheMessagesfor ruletheRule
tell application "Finder"
set folderName to "Downloads"
set homePath to (path to home folder as text) as text
set attachmentsFolder to (homePath & folderName) as text
end tell
tell application "Mail"
repeat with eachMessage in theMessages
set attachCount to count of (mail attachments of eachMessage)
(* !!! Hier komme ich nicht weiter !!!*)
(* Es soll ein Unterordner erstellt werden, der den Namen der Dateiendung trägt*)
set subFolder to ("Attachment_extension")
if attachCount is not equal to 0 then
-- use the unix /bin/test command to test if the timeStamp folder exists. if not then create it and any intermediate directories as required
if (do shell script "/bin/test -e " & quoted form of ((POSIX path of attachmentsFolder) & "/" & subFolder) & " ; echo $?") is "1" then
-- 1 is false
do shell script "/bin/mkdir -p " & quoted form of ((POSIX path of attachmentsFolder) & "/" & subFolder)
end if
try
repeat with theAttachment in eachMessage'smail attachments
set originalName to name of theAttachment
set savePath to attachmentsFolder & ":" & subFolder & ":" & originalName
try
savetheAttachmentinfile (savePath)
end try
end repeat
end try
end if
end repeat
end tell
end perform mail action with messages
end using terms from
on pad(n)
return text -2 thru -1 of ("0" & n)
end pad