clip.save local hwnd = win.handle("c=TTOTAL_CMD") static XX = "c:\utils\xxcopy\xxcopy.exe" static Slash = "\" static Quote = esc(?+\"+, ?+\+) clip.clear win.sendmessage(hwnd, 0x400+51, 2029, 0) wait.for(clip.get) local Path = clip.get local Drive = slice(Path, 3) clip.load local Name, Result if(not file.validpath(Drive)) do messagebox("ok error", "Unknown drive: " ++ Drive, "Invalid path") quit endif if(length(Path) > 3) do Name = file.nametype(Path) Path = file.folder(Path) else Result = "First folder in root visited. Go to the previous drive?" if(messagebox("yesno warning", Result, Path ++ " root") == 7) quit win.sendmessage(hwnd, 0x400+51, 2052, 0) win.sendmessage(hwnd, 0x400+51, 2001, 0) quit endif Result = Up(Path, Name) if(Result == ".") quit if(not Result) do tc.cd(hwnd, Path) keys {home} quit endif Path = Result Result = Lowest(Path) tc.cd(hwnd, Result) keys {home} quit Function Up(Path, Name) local FullPath = Path ++ Slash ++ ifelse(Name, Name ++ Slash) Path = PutQuote(Path ++ "\*.*") FullPath = trim(FullPath, Quote, 3) local Report = miscplugin.tempfilename() local Str = Path ++ " /ltree /dl2 /h /fo" ++ Report local ExitCode = file.runwait(0, XX, Str, "", "hide") if(ExitCode != 0 && ExitCode != 100) do messagebox("ok error", "XXcopy error #" ++ ExitCode, "TreeUpX Script") quit(".") endif local Temp = file.readall(Report) local v = vec.createfromlines(Temp) if(v <= 0) do messagebox("ok error", "Vector not created", "VEC plugin error") quit(".") endif v.sortstring Temp = v.binsearch(FullPath) if(Temp == 1) do quit else quit(v[Temp - 1]) endif Function Lowest(Path) local Param = PutQuote(Path ++ "*.*") local Report = miscplugin.tempfilename() local Str = Param ++ " /ltree /h /fo" ++ Report local ExitCode = file.runwait(0, XX, Str, "", "hide") if(ExitCode != 0 && ExitCode != 100) do messagebox("ok error", "XXcopy error #" ++ ExitCode, "TreeUpX Script") quit(".") endif if(file.size(Report) + 1 == length(Path)) quit local Temp = file.readall(Report) local v = vec.createfromlines(Temp) if(v <= 0) do messagebox("ok error", "Vector not created", "VEC plugin error") quit(".") endif v.sortstring Temp = v.length quit(v[Temp - 1]) Function PutQuote(Str) if(find(Str, " ") != -1) do Str = trim(Str, Quote, 3) Str = Quote ++ Str ++ Quote endif quit(Str)