10.6. Exercises

  1. Modify the program that slides the Finder window from the top-left corner down to the right so that it moves instead from the bottom-left corner up to the top right of the screen. Assume you're working with a screen size of 1280 × 854 pixels.

  2. Type and run the following program, noting the output that appears in the Result pane:

    tell application "Finder" to set fileRef to get home
    fileRef

    Based on the result, write the following AppleScript statements. Be sure to test them and verify that you get the correct result.

    1. Rewrite the file reference as nested tell blocks.

    2. Write an AppleScript statement to get the Mac path equivalent for fileRef.

    3. Write an AppleScript statement to get the POSIX path equivalent for fileRef.

    4. Write an AppleScript statement to coerce fileRef into an alias.

  3. The following statement assigns the name of a text file in Linda's home folder to the variable todoFile.

    set toDoFile to "Macintosh HD:Users:linda:ToDo.txt"

    Given this assignment, write statements to do the following (as independent steps) in the Finder:

    1. Get the size of the file.

    2. Copy the file into your Documents folder.

    3. Rename the file to ToDoOld.txt.

    4. Delete the file.

    5. Create a new folder in your home directory called ToDoFolder and then move the file into the newly created folder.

    6. Count the number of files that start with ToDo in your home folder.

    7. Count the number of files that contain ToDo in their name in your home folder.

  4. Write a program to use the Finder to create an Internet location file on your desktop ...

Get Beginning AppleScript® 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.