I got a solution Ulrich What do you think? It could be done in another way? The code for search button is the same not changed a lot only a fix its done:
Code:
folderpath = Dialog.FolderBrowse("Please select a folder:", "d:\\"); StatusDlg.Show() tFolders = Folder.Find(folderpath, "CAT-*", true, nil);--search for folder with naming convention whose begins with "CAT-namefolder", eg: CAT-PhotoSports StatusDlg.Hide() if (tFolders == nil) then Dialog.TimedMessage("Please Wait...", "Theres not folders to search for", 2000, MB_ICONINFORMATION); else for i,v in pairs (tFolders) do tFiles = File.Find(v, "*.*", true, false, nil, nil) nSize = 0; if tFiles ~= nil then for x,y in pairs(tFiles) do nSize = nSize+File.GetSize(y); end end result = Dialog.TimedMessage("Notice", "Adding folder\r\n:"..v, 10, MB_ICONINFORMATION); ListBox.AddItem("ListBox1", v .. " - " .. String.GetFormattedSize(nSize, FMTSIZE_AUTOMATIC, true), v); end totalFound = ListBox.GetCount("ListBox1"); Dialog.Message("Notice", "Total found "..totalFound, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1); Application.ExitScript(); end
Code:
ListBox.SelectItem("ListBox1", LB_ALLITEMS); ListBox.SetUpdate("ListBox1", false); count = ListBox.GetCount("ListBox1"); setEmpty = false; if count == 0 then Dialog.TimedMessage("Please Wait...", "Select a item, it seems empty", 2000, MB_ICONINFORMATION); else local tbDeleteFiles = ListBox.GetSelected("ListBox1"); if(tbDeleteFiles) then for t, data in pairs (tbDeleteFiles) do local strPathFileToDelete = ListBox.GetItemData("ListBox1",tbDeleteFiles[t]); if(strPathFileToDelete ~= "") then File.Delete(tbDeleteFiles[t].."\\*.*", false, false, false, nil); Folder.DeleteTree(strPathFileToDelete, nil); end Page.StartTimer(100, 10); end else Dialog.Message("Error", "Select an item from listbox", MB_OK, MB_ICONEXCLAMATION); end end
Code:
current = ListBox.GetSelected("ListBox1"); setEmpty = false; if current ~= nil then local tbToVerifyFolder = ListBox.GetSelected("ListBox1"); if(tbToVerifyFolder) then for n, data in pairs (tbToVerifyFolder) do local strVerify = ListBox.GetItemData("ListBox1",tbToVerifyFolder[n]); if(strVerify ~= "") then exist = Folder.DoesExist(tbToVerifyFolder[n]) if exist == false then ListBox.DeleteItem("ListBox1", n); ListBox.SetUpdate("ListBox1", true); end end end end if (ListBox.GetCount("ListBox1")) == 0 then setEmpty = true; if setEmpty == true then ListBox.DeselectItem("ListBox1", -1); Dialog.Message("Notice", "Deletion successful", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1); Page.StopTimer(10); end end end
Leave a comment: