Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How to remove or replace text from within AppleScript text

I know that there are ways to convert text to file names, but what I want to do is a little different.

set thetextwithending to "thistext.end" as text

if thetextwithending ends with ".end" then
setthetextwithoutending to (thetextwithending - ".end" from the ending)
end if

I expect that it's something like this (although I know my syntax is wrong, I think my logic is correct):

set thetextwithoutending to "Nope. Didn't work." as text

if thetextwithending ends with ".end" then
theCount to (the number of characters in thetextwithending) as number
set theFixedCount to (theCount - 4) as number
set thetextwithoutending to (theFixedCount characters of thetextwithending) as text
end if

thetextwithoutending

PowerBook G4 1.67 Ghz, Mac OS X (10.5.5)

Posted on Sep 22, 2010 5:15 PM

Reply
Question marked as Best reply

Posted on Sep 22, 2010 5:19 PM

Here:

set thetextwithending to "thistext.end" as text

if thetextwithending ends with ".end" then
set thetextwithoutending to items 1 thru -5 of thetextwithending as string
end if

(53910)
3 replies

How to remove or replace text from within AppleScript text

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.