beautypg.com

Apple AppleScript Finder Guide User Manual

Page 130

background image

C H A P T E R 3

Finder Commands

118

Command Definitions

Exists

3

An Exists command is a request to determine whether the object specified by a

reference exists. The Finder version of the Exists command is identical to the

standard version described in the AppleScript Language Guide.

SYNTAX

exists

referenceToObject

referenceToObject exists

PARAMETER

referenceToObject

A reference to the object to find or a list of references.

Class:

Reference or list of references

RESULT

A Boolean value. If true, all of the objects referred to by referenceToObject exist.

If false, one or more of the objects referred to by referenceToObject do not exist.

EXAMPLE

This script checks whether a disk named Storage is mounted and, if it is, copies

all files from the folder Correspondence whose modification dates are more

than 30 days old to disk Storage and deletes the originals.

tell application "Finder"

if exists disk "Storage" then

set aMonthAgo to (current date) - (30 * days)
copy (every item in folder "Correspondence" of startup disk ¬

whose modification date < aMonthAgo) ¬
to folder "Old Letters" of disk "Storage"

delete (every item in folder "Correspondence" of startup disk ¬

whose modification date < aMonthAgo)