• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: / change to '.' in saving code
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: / change to '.' in saving code


  • Subject: Re: / change to '.' in saving code
  • From: Yvan KOENIG <email@hidden>
  • Date: Tue, 03 Jan 2017 17:13:38 +0100

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


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: / change to '.' in saving code
      • From: Brian Christmas <email@hidden>
References: 
 >/ change to '.' in saving code (From: Brian Christmas <email@hidden>)

  • Prev by Date: Re: / change to '.' in saving code
  • Next by Date: Re: / change to '.' in saving code
  • Previous by thread: Re: / change to '.' in saving code
  • Next by thread: Re: / change to '.' in saving code
  • Index(es):
    • Date
    • Thread