Coercion problem
Coercion problem
- Subject: Coercion problem
- From: Al Wirtes <email@hidden>
- Date: Thu, 10 Jun 2004 15:40:13 -0600
I'm having trouble with a script to copy a folder from a server to a local
space. Here's the script:
set OrigPath to "Active Formats:"
set CopyPath to "Macintosh HD:Users:wirtes:desktop:Local Formats:"
set LNum to text returned of (display dialog "Input Format ID without the F"
default answer "1234" buttons {"OK"} default button 1) as integer
-- pick your hashed directory
if (LNum < 501) then
set LHash to "0001-0500:"
else if (LNum < 1001) then
set LHash to "0501-1000:"
else if (LNum < 1501) then
set LHash to "1001-1500:"
else if (LNum < 2001) then
set LHash to "1501-2000:"
else if (LNum < 2201) then
set LHash to "2001-2200:"
else if (LNum < 2501) then
set LHash to "2501-3000:"
else if (LNum < 3501) then
set LHash to "3001-3500:"
else if (LNum < 4001) then
set LHash to "3501-4000:"
else if (LNum < 4501) then
set LHash to "4001-4500:"
else if (LNum < 5001) then
set LHash to "4501-5000:"
else if (LNum < 5501) then
set LHash to "5001-5500:"
else if (LNum < 6001) then
set LHash to "5501-6000:"
end if
-- set Format number back to a string & add leading zeros
set LNum to LNum as string
if (length of LNum = 1) then
set LNum to "000" & LNum
else if (length of LNum = 2) then
set LNum to "00" & LNum
else if (length of LNum = 3) then
set LNum to "0" & LNum
end if
set OrigPath to OrigPath & LHash
tell application "System Events"
set this_file to (every folder whose name starts with LNum) of folder
OrigPath
end tell
if (number of items in this_file = 0) then
-- Format doesn't exist
display dialog ("Format F" & LNum & " doesn't exist!")
else if (number of items in this_file > 1) then
-- Too many format folders exist
display dialog ("There are " & (number of items in this_file) & "
folders for F" & LNum & ". Fix this ASAP!")
else if (number of items in this_file = 1) then
-- copy the Format!
tell application "Finder"
try
duplicate folder (this_file as alias) to folder (CopyPath
as alias)
on error errText number errNum
display dialog errText & number & errNum
end try
end tell
end if
This script gets a "format ID" from the user and then looks in a server for
a folder that begins with that format ID (LNum). Once I have the directory,
I do a quick check to make sure that I've gotten one - and only one -
directory (this_file). Then I want to copy the directory (this_file) to my
local HD, (CopyPath).
The trouble comes in when I try to coerce this_file, which is a list
containing one item, into an alias. I get the following error in the event
log:
display dialog "Can't make Gclass cfolH \"Active
Formats:4001-4500:4234 Al's Book:\" of application \"System Events\" into a
alias.number-1700"
{button returned:"OK"}
Any ideas why I can't coerce something of class cfol into class alias? I
can't figure out what I'm doing wrong.
Thanks much,
-Al Wirtes
PrePress Manager
Dataworks
email@hidden <
mailto:email@hidden>
_______________________________________________
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.