Re: New scripter Q: Success, but a couple of questions.
Re: New scripter Q: Success, but a couple of questions.
- Subject: Re: New scripter Q: Success, but a couple of questions.
- From: email@hidden
- Date: Sat, 8 Mar 2003 20:03:11 EST
Finally, I found successful solution. But there were a few bumps along the
way which are puzzling.
To recap: I had an issue whereby I wished to copy a file from a CD-ROM that
changed by number every week (diskName & (1 to 2 to 3, etc.)). Both the file
and the folder it resided in had identical names plus the same number as the
disk, and that's where the problem was. [OS 8.6]
This final script worked very well:
tell application "Finder"
activate
set drvName to (name of every disk whose name begins with "Heinz")
set fldrName to (name of every folder of disk drvName whose name starts
with "Heinz List")
set fileName to (name of every file of folder (fldrName) of disk
(drvName) whose name starts with "Heinz List")
copy (file (fileName) of folder (fldrName) of disk (drvName)) to item
"Macintosh HD:Heinz"
end tell
. . . but first I had to change the name of the destination folder to
"Hz1". After the script executed it was then changed back to "Heinz". No
problems. The thing worked. Why I had to do this, however, is puzzling. I had
previously copied the name of the folder into the script from the folder
itself, for accuracy. What then happened, according to the Event Log, was
this:
Script:
tell application "Finder"
activate
set drvName to (name of every disk whose name begins with "Heinz")
select disk (drvName)
open selection
set fldrName to (name of every folder of disk drvName whose name starts
with "Heinz List")
select folder (fldrName) of disk drvName
open selection
set fileName to (name of every file of folder (fldrName) of disk
(drvName) whose name starts with "Heinz List")
select file (fileName) of folder (fldrName) of disk drvName
copy (file (fileName) of folder (fldrName) of disk (drvName)) to folder
"Heinz" of startup disk
end tell
Event Log (truncated):
tell application "Finder"
activate . . .
[Deleted results] . . .
select file "Heinz List (57)" of folder "Heinz List (57)" of disk "Heinz
57"
--> file "Heinz List (57)" of folder "Heinz List (57)" of disk "Heinz
57"
copy file "Heinz List (57)" of folder "Heinz List (57)" of disk "Heinz
57" to folder "Heinz" of startup disk
--> Finder got an error: Can't set folder "Heinz" of startup disk to
folder "Heinz" of startup disk.
That last result is what's confusing me, since it isn't even close to what
the command above it was asking for. Substituting "open selection" for that
last command worked, so it wasn't a matter of an incorrect path. Any ideas?
Also, could someone explain why "duplicate . . . with replacing" works, but
"copy . . . with replacing" results in a syntax error? (Can't put "with
replacing" after this . . .)
Mike
email@hidden
**********************************************
"The secret of life is honesty and fair dealing.
If you can fake that, you got it made."
bGroucho Marx
_______________________________________________
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.