• 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: Brian Christmas <email@hidden>
  • Date: Tue, 03 Jan 2017 22:54:01 +1100

G’day Yvan

Just before you sent this email, I realized it was Mail itself changing the name, so I used your code from several days ago to change then colons back.

Thank you though, you’ve shown me a shortcut with this new coding.

Regards

Santa


On 3 Jan 2017, at 9:41 pm, Yvan KOENIG <email@hidden> wrote:


Le 4 janv. 2017 à 07:04, Brian Christmas <email@hidden> a écrit :


G’day

I’ve been using Shanes code to save new files under 10.12.2 with great results, until I tried to handle os file name "MM Testing 12/20/16.pdf”.

Then the handler returned an error…

Attachment saving error  p = 102 File file Brian's Disk:Users:OzSanta:Desktop:Mail Manager Folder:Temporary Printing:2017 01 04 054841:MM Testing 12:20:16.pdf wasn’t found. number = -43

which I supposed is to be expected. The code is below…

Are there any alterations I can make that will allow the use of a forward slash in a file name?

Yvan, will your code posted on 28th December handle this dilemma?

(1) Your problem is related to the fact that when a filename contains a slash, Mail doesn't return its Hfs name but it's Posix one.
Your attached file is named "MM Testing 12/20/16.pdf” but the name returned by Mail is "MM Testing 12:20:16.pdf”.
As the rest of your script use Hfs path it logically fails.

You would have to use something like :

use AppleScript version "2.4"
use framework "Foundation"
use scripting additions

#…
set originalPOSIXName to "MM Testing 12:20:16.pdf" # Maybe this POSIX version would be useful somewhere
copy originalPOSIXName to originalName
if originalName contains ":" then set originalName to my replace:originalName existingString:":" newString:"/"
--> "MM Testing 12/20/16.pdf"
#…
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:

CAUTION: the replace handler used here is not the one used in one of my mauls of december 28th.

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) mardi 3 janvier 2017 11:41:14

 _______________________________________________
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

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

  • Prev by Date: / change to '.' in saving code
  • Next by Date: Re: AppleScript-Users Digest, Vol 14, Issue 1
  • Previous by thread: / change to '.' in saving code
  • Next by thread: Re: / change to '.' in saving code
  • Index(es):
    • Date
    • Thread