Re: Newbie Question
Re: Newbie Question
- Subject: Re: Newbie Question
- From: email@hidden
- Date: Mon, 10 Dec 2001 12:39:32 EST
>
>In a message dated 12/10/2001 "Mike F." writes:
>
>I'm new not only to this list, but to AppleScript as well. I'm trying to
create a script that will perform a few operations and I need a little help.
Here is what I want to do:
>
>-look for a file in a specific folder on a server (file name will change a
bit)
>
>-copy this file to a specific folder on the local drive
>
>It seems pretty basic but I have a few questions.
Mike: I won't pretend to be an expert in such things, but here are some
samples that might help you get started. It works on OS 9.1:
>
>1) When looking for a server, does the server's drive have to be mounted on
the desktop? If so, how do I (in the script) tell it to look for a path that
doesn't exist?
if (list disks) does not contain "nameOfDisk" then
try
mount volume "nameOfDisk" on server "nameOfServer" in AppleTalk zone
"zone" as user name "name" with password "password" -- all one line
on error
return
end try
end if
You might not need the zone, name and password parameters, depending on your
network. And you might want to do something, such as display a warning, if
the volume can't be mounted. My experience, though, suggests that most users
will simply ignore those warnings.
>
>2) I noted the file name might change a bit -- for example, the file name
might be named 'File1.001' one day, but the next day it might be 'File1.002'.
Basically, the 'File1' will stay the same -- only the last 3 digits will
change. I currently have a dialogue box that asks for the three digits. I
want to take the 3 digits the user enters and use it to determine what file to
get.
>
>3)Lastly, I want to produce a non-trivial error message if the file doesn't
exist. >>
set theSuffix to text returned of (display dialog "Enter a three-digit
number" default answer "000")
set thePath to "disk:folder:File1." & theSuffix
tell application "Finder"
if not (exists file thePath) then
display dialog "File1." & theSuffix & " does not exist!"
else
--clever things happen here!
end if
end tell
I suspect that there might be a better way to handle the file-exists test. By
the time this comes back in the digest, better ways might be posted.
HTH
Robert Kyle
Star Tribune
Minneapolis