• 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
/ change to '.' in saving code
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

/ change to '.' in saving code


  • Subject: / change to '.' in saving code
  • From: Brian Christmas <email@hidden>
  • Date: Wed, 04 Jan 2017 17:04:26 +1100


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?

Regards

Santa

repeat with eachAttachment from 1 to my attachmentCounter
set theAttachment to item eachAttachment of attachmentList
tell application "Mail" to set originalName to name of theAttachment
set x to 0
set addOnText to ""
#
# This 'repeat to set new Attachment name' is necessary because 'Mail' messages can
# contain more than one Attachment with same name.
#
set thisChar to "."
set offSetText to (length of originalName) - (offset of thisChar in (reverse of text items of originalName as string))


set theNameStart to (characters 1 through offSetText of originalName) as Unicode text
try
set theNameExtension to (characters (offSetText + 1) through -1 of originalName) as text
on error
set theNameExtension to "" # Folder
end try
set exitFlag to false
#
 repeat
try
set savedAttachmentPath to ((my holdingFolder) & theNameStart & addOnText & theNameExtension as Unicode text)
tell application "Finder"
set existsFile to exists (item savedAttachmentPath)
end tell
on error errmsg
tell application "System Events" to display dialog "subroutineOne internal repeat " & errmsg giving up after 20
end try
  if existsFile then
set x to x + 1
set addOnText to (" copy " & x) as text
else
try
# NEW Code
set p to 100
set pathToFile to savedAttachmentPath as Unicode text
-- create file
set p to 101
set theFile to pathToFile as «class furl»
set p to 102
set fileRef to open for access theFile with write permission
set p to 103
close access fileRef
set p to 104
tell application "Mail"
set p to 105
tell theAttachment
set p to 106
save in theFile
end tell
end tell
exit repeat
on error errmsg number errnum
if errnum ≠ -10000 then
if my runForOz then tell application "System Events" to display dialog "Attachment saving error  p = " & p & " " & errmsg & " number = " & errnum giving up after 20
set my attachmentMailFlag to "Errors found"
end if
exit repeat
end try
end if
end repeat
  end repeat




 _______________________________________________
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: Yvan KOENIG <email@hidden>
    • Re: / change to '.' in saving code
      • From: Pat Stanford <email@hidden>
  • Prev by Date: Re: Setting "Make Plain Text" in Mail
  • Next by Date: Re: / change to '.' in saving code
  • Previous by thread: Re: Setting "Make Plain Text" in Mail
  • Next by thread: Re: / change to '.' in saving code
  • Index(es):
    • Date
    • Thread