Re: 1 to 001 & the duplicate command
Re: 1 to 001 & the duplicate command
- Subject: Re: 1 to 001 & the duplicate command
- From: Nigel Garvey <email@hidden>
- Date: Sun, 2 Jun 2002 18:09:13 +0100
Stephen Swift wrote on Sat, 01 Jun 2002 11:44:20 -0400:
>
At 5/31/02 3:36 AM, Nigel Garvey (email@hidden) Wrote:
>
>
> There is indeed a bug in 8.6 (fixed in later versions) where 'duplicate'
>
> returns the original item instead of the duplicate. You have to set up
>
your
>
> own reference to the duplicate, using the expected name and the folder to
>
> which you've duplicated the item. I'm away from my 8.6 machine at the
>
moment,
>
> so I can't check what the implications are for the duplicate's name if
>
another
>
> duplication has already occurred.
Back home for the weekend, I see that in addition to the above, if you
just duplicate an item without specifying a destination folder, 8.6
returns an empty list.
>
Okay, until I upgrade I'll just have to think of a workaround. Would
>
referring to files by their ID's work?
It seems so, but comparing names might be quicker as you can then use
'list folder':
on duplicate8_6(theItem, destFolder) -- 'theItem' can be a list of items
tell application "Finder"
-- Avoid a possible problem with the desktop
set destFolder to destFolder as string as alias
-- Note the existing contents of the destination folder
set olderItems to list folder destFolder
-- Perform the duplication
duplicate theItem to destFolder
-- Get a list of the items that have just appeared
get items of destFolder whose name is not in olderItems
-- Imitate the return from a non-bugged 'duplicate'
if (count result) is 1 then
return item 1 of result
else
return result
end if
end tell
end duplicate8_6
tell application "Finder"
my duplicate8_6(file "test file" of folder "test folder", folder
"test folder")
--> file "test file copy" of folder "test folder" of application
"Finder"
my duplicate8_6(every file of folder "test folder", folder "test
folder")
--> {file "test file copy 1" of folder "test folder" of application
"Finder", file "test file copy 2" of folder "test folder" of application
"Finder"}
end tell
NG
_______________________________________________
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.