on open (ItemList)
tell application "Finder"
set fdir to the target of front window as text
set fname to the name of front window as text
set AppleScript's text item delimiters to {""}
set x to (length of fname) + 2
set fdir1 to characters 1 thru -2 of fdir as string
if fdir1 is not fname then --is current window at root of hd?
set up1 to (characters 1 thru -x of fdir) as string
set AppleScript's text item delimiters to {" "}
move selection to up1
set target of front window to up1
end if
end tell
end open
on run
tell application "Finder"
set fdir to the target of front window as text
set fname to the name of front window as text
end tell
set AppleScript's text item delimiters to {""}
set x to (length of fname) + 2
set fdir1 to characters 1 thru -2 of fdir as string
if fdir1 is not fname then --is current window at root of hd?
set up1 to (characters 1 thru -x of fdir) as string
set AppleScript's text item delimiters to {" "}
tell application "Finder"
set target of front window to up1
end tell
end if
end run