clip.save local hwnd = win.handle("c=TTOTAL_CMD") local Panel = ifelse(tc.active(hwnd) == "left", 8, 7) local Drive = childwin.handle(hwnd, "TMyListBox", Panel) local Result = win.sendmessage(Drive, 0x0188, 0, 0) static Slash = "\" static Quote = esc(?+\"+, ?+\+) clip.clear win.sendmessage(hwnd, 0x400+51, 2029, 0) wait.for(clip.get) local Path = clip.get Drive = slice(Path, 3) local Name if(not file.validpath(Drive)) do messagebox("ok error", "Unknown drive: " ++ Drive, "Invalid path") clip.load quit endif if(not Result && Path == Drive) do win.sendmessage(hwnd, 0x400+51, 2017, 0) wait.for(clip.get) Name = clip.get tc.cd(hwnd, Path ++ Name) clip.load quit endif if(Result) do win.sendmessage(hwnd, 0x400+51, 2017, 0) wait.for(clip.get) Name = clip.get endif clip.load local FullPath = Path ++ Slash ++ Name if(file.isfolder(FullPath) && Name) do win.sendmessage(hwnd, 0x400+51, 2003, 0) 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)