The following behaviour seems strange to me:
tell application "Finder"
set Window1Name to name of window 1
repeat with aWindow in every window
display dialog ">" & name of aWindow as string
end repeat
end tell
The "display dialog" displays the name of a file in the Finder window, not the name of the Finder window.
On the second time through the repeat loop it generates an error saying "Finder got an error: Can't get name of item 2 of every window".
The following more cumbersome code operates correctly:
tell application "Finder"
set Window1Name to name of window 1
set i to 1
repeat
try
name of window i
on error
exit repeat
end try
display dialog ">" & name of window i as string
set i to i + 1
end repeat
end tell
Any explanations?