Folder Structure

The following script works well for opening a explorer shell but doesn't always open up the same folder when you max file is 1 folder deeper.

I like to change it so it still looks at the root of the current file that is open; it then counts up to a rootdept of 3. Instead of counting down from the currently file directory and counts 3 folders back.

Hope that is a bit clear.
Thanks

(
----------------------------------------------------------------------------------------------------
--Change the following number to represent the amount of folder levels you wish to go up--
----------------------------------------------------------------------------------------------------
local rootdepth = 3 as integer
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------

fn removeLastDir thePath =
(
theFS = filterString thepath "\\"
theNewPath = ""
for i = 1 to theFS.count-rootdepth do theNewPath += theFS[i] + "\\"
theNewPath
)

local rootpath = ""
rootpath = removelastdir maxfilepath

shelllaunch "c:\\windows\\explorer" ("/e," + rootpath)

)