local FullPath = x9 local hwnd = win.handle("c=TTOTAL_CMD") static Quote = esc(?+\"+, ?+\+) static Slash = "\" local Path = file.folder(FullPath) Path = trim(Path, " ", 3) Path = trim(Path, Quote, 3) local Result = slice(Path, 3) local Name = file.nametype(FullPath) Name = trim(Name, Quote, 3) FullPath = Path ++ Slash ++ Name if(file.isfolder(FullPath) && Name) do win.sendmessage(hwnd, 0x400+51, 2003, 0) quit endif if(not file.validpath(Result)) do messagebox("ok error", "Unknown drive: " ++ Result, "Invalid path") quit endif if(not file.isfolder(FullPath)) do if(length(Path) <= 3) do Result = "Last folder in root visited. Go to the next drive?" if(messagebox("yesno warning", Result, Path ++ " root") == 7) quit win.sendmessage(hwnd, 0x400+51, 2051, 0) win.sendmessage(hwnd, 0x400+51, 2001, 0) quit endif Name = file.nametype(Path) Path = file.folder(Path) endif for(1) Result = Down(Path, Name) if(Result == ".") quit if(not Result) do if(length(Path) <= 3) do Result = "Last folder in root visited. Go to the next drive?" if(messagebox("yesno warning", Result, Path ++ " root") == 7) quit win.sendmessage(hwnd, 0x400+51, 2051, 0) win.sendmessage(hwnd, 0x400+51, 2001, 0) quit endif Name = file.nametype(Path) Path = file.folder(Path) else tc.cd(hwnd, Result) keys {home} quit endif endfor quit Function Down(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, "c:\utils\xxcopy\xxcopy.exe", Str, "", "hide") if(ExitCode != 0 && ExitCode != 100) do messagebox("ok error", "XXcopy error #" ++ ExitCode, "TreeDownX Script") quit(".") endif if(file.size(Report) - 2 == length(FullPath)) 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.binsearch(FullPath) if(Temp == -1 || Temp + 1 == v.length) do quit else quit(v[Temp + 1]) endif quit Function PutQuote(Str) if(find(Str, " ") != -1) do Str = trim(Str, Quote, 3) Str = Quote ++ Str ++ Quote endif quit(Str)