It seems that my first answer is lost somewhere in the Atlantic Ocean.
Your problem is due to an old feature.
When we ask it to return the name of an attachment, Mail doesn't return what we see in the Finder but what is stored in a POSIX pathname. As what I'm accustomed to name the HfsName is "MM Testing 12/20/16.pdf”, Mail returns what I'm accustomed to name the POSIXname : "MM Testing 12:20:16.pdf”.
According to that you must bring some changes to your code.
use AppleScript version "2.4" use framework "Foundation" use scripting additions
# … repeat with eachAttachment from 1 to my attachmentCounter set theAttachment to item eachAttachment of attachmentList tell application "Mail" to set originalPOSIXname to name of theAttachment --> "MM Testing 12:20:16.pdf” # You may use it to build POSIX paths or for comparisons with Mail's data set originalName to (my replace:originalPOSIXname existingString:":" newString:"/") --> "MM Testing 12/20/16.pdf” # Now you may use it to build your Hfs paths #… end repeat
on replace:sourceString existingString:d1 newString:d2 set sourceString to current application's NSString's stringWithString:sourceString return (sourceString's stringByReplacingOccurrencesOfString:d1 withString:d2) as text end replace:existingString:newString:
Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) mardi 3 janvier 2017 17:12:09
|