Name
ends with
Syntax
"index.html" ends with ".html" -- returns true
Return value
boolean
; true
or
false
Description
This operator is invaluable when searching a disk or folder for files
with certain file extensions (e.g., .html, .gif ) and then
doing something only with those found files. The ends with
operator works with lists and strings. If you use this
operator to compare a string
with a
list
or vice versa, then AppleScript tries to
coerce the string
or list
to
the type of the left operand.
Examples
{"apples", "oranges"} ends with "oranges" -- returns true "oranges" ends with {"n","g","e","s"} (* true, after AppleScript coerces the right operand from list to string, after which it looks like "nges" *) {"img1.gif", "img2.gif"} ends with ".gif" -- false {"img1.gif", "img2.gif"} ends with "img2.gif" -- true
Get AppleScript in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.