Alias list not a list of aliases !?!
Alias list not a list of aliases !?!
- Subject: Alias list not a list of aliases !?!
- From: Mr Tea <email@hidden>
- Date: Tue, 23 Apr 2002 08:01:56 +0100
I don't understand.
With items selected in the Finder's front window, if I ask the Finder for
'selection as alias list' I get a list of file references as the result. Not
an alias in sight. (This is in OS X 10.1.4.)
Surely that's very, very wrong.
I ran into this while refining a script that moves items up through the
folder heirarchy in icon view windows and sets the target of the window to
follow the file. I wanted to reselect the moved items with the script after
changing the window's target, and this requires aliases to avoid a lot of
onerous checking of folder contents.
Try as I might, I couldn't get the Finder to return an alias list. In the
end, I knocked up this workaround:
set theFiles to selection
if (count of theFiles) > 1 then
set theList to {}
repeat with aFile in theFiles
set end of theList to aFile as alias
end repeat
set theFiles to theList
It's effective, but why is it needed? Am I doing something wrong?
For anyone interested, here's the whole script, warts 'n' all. It can be a
real time-saver if you're stubborn enough to have persisted with icon views
in OS X...
set moveUp to true
tell application "Finder"
set theWindow to Finder window 1
set theNewTarget to container of folder of theWindow
try
if current view of theWindow is icon view then
set theFiles to selection
if (count of theFiles) > 1 then
set theList to {}
repeat with aFile in theFiles
set end of theList to aFile as alias
end repeat
set theFiles to theList
else if (count of theFiles) = 1 then
if item 1 of theFiles target of theWindow then
set theFiles to selection as alias
else
set theWords to "No items are selected"
display dialog theWords buttons {"Sorry"} default button 1 with
icon note
set moveUp to false
end if
end if
if moveUp then
move theFiles to theNewTarget
set target of theWindow to theNewTarget
select theFiles
end if
else
set theWords to "The window must be set to icon view to use this
script"
display dialog theWords buttons {"Sorry"} default button 1 with icon
note
end if
on error errmsg number errNum
set theWords to "Error " & errNum & return & return & errmsg
display dialog theWords buttons {"Sorry"} default button 1 with icon
caution
end try
end tell
I'd like to extend the script's scope to include list views, but I haven't
cracked that one yet. Something strange going on...
Mr Tea
_______________________________________________
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.