set Showsidebar to true
tell application "Finder"
activate
if exists window 1 then
set allwins to every window whose collapsed is false
set my_num to 0
repeat with onewin in allwins
set my_num to my_num + 1
tell application "System Events"
tell process "Finder"
set my_id to the name of onewin
tell application "Finder"
try
set my_test to get ¬
toolbar visible of window my_id
on error
set my_test to false
end try
end tell
if my_test then
tell application "Finder"
if window my_id is window 1 then
set the_place to get sidebar width of window my_id
if the_place = 0 then
set Showsidebar to true
else
set Showsidebar to false
end if
end if
end tell
end if
tell application "Finder"
if index of window my_id ≠1 then
open window my_id
else
if Showsidebar then
tell application "Finder"
tell front window to set sidebar width to 150
end tell
else
tell application "Finder"
tell front window to set sidebar width to 0
end tell
end if
end if
end tell
end tell
if my_test then
if Showsidebar then
tell application "Finder"
tell front window to set sidebar width to 150
end tell
else
tell application "Finder"
tell front window to set sidebar width to 0
end tell
end if
end if
end tell
tell application "Finder"
set index of window my_id to my_num
end tell
end repeat
end if
end tell