Re: Manipulate the last item in a string
Re: Manipulate the last item in a string
- Subject: Re: Manipulate the last item in a string
- From: Bill White <email@hidden>
- Date: Sat, 17 Jun 2006 09:18:15 -0400
- Thread-topic: Manipulate the last item in a string
On 6/17/06 8:04 AM, Marine Themes <email@hidden> wrote:
> "1234.jpg, 5678.jpg, 4444.jpg, 5555.jpg, 9876.jpg, 6969.jpg."
>
> What I want to do is delete the last comma and insert an "&" into the
> string to make:
>
> "1234.jpg, 5678.jpg, 4444.jpg, 5555.jpg, 9876.jpg & 6969.jpg."
>
> I assume that I use text item deliminators but not sure how as there are
> multiple ", " in the string and record names will vary with each use of
> the script. Any suggestions?
Clive,
See if this works for you (watch line wraps):
set theString to "1234.jpg, 5678.jpg, 4444.jpg, 5555.jpg, 9876.jpg,
6969.jpg." -- should be on one line
set AppleScript's text item delimiters to ", "
try
set firstPart to text items 1 thru -2 of theString
set secondPart to text item -1 of theString
set finalString to (firstPart as string) & " & " & secondPart
set AppleScript's text item delimiters to ""
on error
set AppleScript's text item delimiters to ""
end try
finalString --> "1234.jpg, 5678.jpg, 4444.jpg, 5555.jpg, 9876.jpg &
6969.jpg." -- again, should be on one line
HTH,
Bill
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden