Re: New scripter Q: calling upon a generic file name?
Re: New scripter Q: calling upon a generic file name?
- Subject: Re: New scripter Q: calling upon a generic file name?
- From: Kai <email@hidden>
- Date: Sat, 01 Mar 2003 04:45:50 +0000
on Thu, 27 Feb 2003 20:38:27 EST, email@hidden wrote:
>
There is an issue, however minor, that I have with calling upon a recurring
>
file by a "generic" name. The only difference is that each week the disk's
>
numbers -- disk, folder and file -- increase by a factor of one.
>
>
If one has a CD-ROM with a name that changes only by number from week to
>
week, but retains its' "first name" I am able to script access to the disk
>
without problems. However, if I need to access a file within a folder that
>
possesses the same name there are hang-ups. For example, if I get a disk
>
named "Heinz 57" I can open the disk by calling upon it as:
>
>
tell application "Finder"
>
activate
>
set drvName to (name of every disk whose name begins with "Heinz")
>
open drvName
>
end tell
>
>
But when I need to open/copy a file named "Heinz 57 List" that sits in a
>
folder named "Heinz 57 List" on the disk named "Heinz 57" I get only a
>
message stating that "an error of the type 13579 has occurred." No
>
explanation for this is given. An example of the script I wrote is as follows:
>
>
tell application "Finder"
>
activate
>
set drvName to (name of every disk whose name begins with "Heinz")
>
copy (((file whose name begins with "Heinz List") of folder whose name
>
begins with "Heinz List") of item drvName) to item "Macintosh HD:Heinz F"
>
end tell
>
>
Please note that no matter where I place the parentheses this error code
>
appears. I'm wondering, first of all, if this error code is legit. Secondly,
>
can someone explain to me why this is happening, and is there a workaround?
>
(Mac OS 8.6)
Firstly, I suspect that the Finder is having difficulty find the right
files, Mike.
For example, in your description above, you say that the required folder and
file are both named "Heinz 57 List". However, your script tells the Finder
to locate a folder and file whose names both begin with "Heinz List". The
trouble is that "Heinz 57 List" doesn't begin with "Heinz List".
Secondly, the Finder's 'whose' filter has been known to be a bit cranky -
and its eccentricities seem to vary from version to version. Sometimes, the
Finder needs to have certain results evaluated before it can continue. So if
you're having difficulty, it may be useful to break the script into more
discreet steps. (This might also help you identify individual problems more
easily.)
The following script works for me - but may need some adjustment to suit
your own system (I couldn't test for OS 8.6) and configuration (you may need
to amend the path "Macintosh HD:Heinz F:" as appropriate):
=========================
tell application "Finder"
set d to (disks whose name begins with "Heinz")'s name
set c to disk d's folders whose name is d & " List"
set f to (c's item 1)'s files whose name is d & " List"
duplicate f to alias "Macintosh HD:Heinz F:"
end tell
=========================
Let me know if you continue to have problems.
--
Kai
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.