PDA

View Full Version : Search for folders with the same name



yhb
11-26-2007, 01:17 PM
Hi guys, was wondering if any of you could me with the code that once i click the button then it will search for folders that has the same folder names in multiple locations and list them all I guess in the list box. There will be 6 folder locations it needs to do the search. Locations will be like below:

6 Locations to do a search: (search only for folder names not files)

d:\active
e:\active
f:\active
g:\active
h:\active
i:\active

it will search only will all those folders and no recurse folder so it will be faster since the only thing I need to know is all inside the active folders on all the drives. :)

The only function for it is just search for folder names tha has the same name and list them all if there is and show it in a list box. :)

Thanks much.

yhb)

yhb
12-14-2007, 10:08 PM
:rolleyes hmmm.... I still believe that one of these days my angel will see my post and help me out.... :D he he he he..

yhb)

holtgrewe
12-14-2007, 11:43 PM
Sorry no one responded earlier...

See if the following works for you.
You should be able to replicate it for each drive.
the command returns a boolean value to determine if the folder exists. (refer to the help document)


does_exist = Folder.DoesExist("D:\\Active");
--
if does_exist then
Dialog.Message("Notice", "Yes, the folder does exist on your system.", MB_OK, MB_ICONINFORMATION);
else
Dialog.Message("Notice", "No, the folder does not exist on your system.", MB_OK, MB_ICONINFORMATION);
end

Optionally, text could be displayed in an input box in lieu of the Dialog.Message.

P.S. : I'm definately no angel. LOL

hth

Mina
12-15-2007, 12:06 AM
Yeah, the angel has arrived
:p

Basically, holtgrewe is absolutely correct. However, to give you less of a hard time, and because you have been specific, (and because im such a nice guy)
Here you go


tblZ = {}
tblCount = 0
--[[1]] does_exist = Folder.DoesExist("d:\\active");
if does_exist then
tblCount = tblCount + 1
tblZ[tblCount] = ("d:\\active")
end

--[[2]] does_exist = Folder.DoesExist("e:\\active");
if does_exist then
tblCount = tblCount + 1
tblZ[tblCount] = ("e:\\active")
end

--[[3]] does_exist = Folder.DoesExist("f:\\active");
if does_exist then
tblCount = tblCount + 1
tblZ[tblCount] = ("f:\\active")
end

--[[4]] does_exist = Folder.DoesExist("g:\\active");
if does_exist then
tblCount = tblCount + 1
tblZ[tblCount] = ("g:\\active")
end

--[[5]] does_exist = Folder.DoesExist("h:\\active");
if does_exist then
tblCount = tblCount + 1
tblZ[tblCount] = ("h:\\active")
end

--[[6]] does_exist = Folder.DoesExist("i:\\active");
if does_exist then
tblCount = tblCount + 1
tblZ[tblCount] = ("i:\\active")
end
-----
--[[Show the results in the listbox]] for tbPOS, folder_found in tblZ do
ListBox.InsertItem("ListBox1", -1, folder_found, "");

end
--[[This will show if nothing gets listed in ListBox1]] listCOUNT = ListBox.GetCount("ListBox1");
if listCOUNT == 0 then
-- none of the folders were found
end

I hope you find this helpful.

yhb
12-15-2007, 06:28 PM
:Dwell, to me you are all are.. he he.. thank you both for the reply, appreciate it. I tried both of the code you guys posted and it seems to work but it just listing the folders that was mentioned in the script and not really telling me if there's any folder(s) exist(s) with the same folder name which I know there is :eek:.... lol

I think I still didn't explain it very well but I'm sure this one will clear it up a lot better than the original post I did. I'll try to show you what's inside the " ACTIVE " folders.

For example the " D:\ACTIVE " folder contains lots of files and sub-folders as well.

......................D:\ACTIVE_
.......................................|
.......................................|
.......................................|_11111_
.......................................|.......... .|_Master
.......................................|.......... .|_Engineering
.......................................|.......... .|_Production
.......................................|.......... .|_MilSpec
.......................................|.......... .|_ISO
.......................................|.......... .|_Misc
.......................................|.......... .|_BackUp
.......................................|
.......................................|
.......................................|_22222
.......................................|
.......................................|
.......................................|_33333
.......................................|
.......................................|
.......................................|_44444<--the blue folder(s) is all I'm concerned not having duplicate folder name(s).....
.......................................|
.......................................|
.......................................|_55555

Now, the sub-folders under " D:\ACTIVE " that I have colored in BLUE are the ONLY folders I DON'T want any duplicate folder name(s) on other locations like... :lol

E:\ACTIVE\
F:\ACTIVE\
G:\ACTIVE\
H:\ACTIVE\
I:\ACTIVE\

I'm just trying to create something I can execute anytime I needed to run it and can SCAN/SEARCH ALL those " ACTIVE " drive folders I have mentioned and will list the duplicate folder names and their exact locations ( if found one or more) :) and so I can easily locate and fix all the duplicate folders it finds. :D

In short, if it finds one or more duplicates folder names then it list in the listbox the folder name(s) and their locations like:


FOUND " 2 " DUPLICATE FOLDER NAME(S).......

D:\ACTIVE\33333
F:\ACTIVE\33333

G:\ACTIVE\12345
H:\ACTIVE\12345

Hopefully, I didn't confuse you more....LOL :D Thank you so much guys for the replies and input. I appreciate this a lot.

yhb)

Mina
12-16-2007, 05:54 AM
I shall color my code too

Here, try this.
(Doesn't check for duplicate folder names though, Ill work on that one later if you need it)


ListBox.DeleteItem("ListBox1", LB_ALLITEMS);
tblDRV = Drive.Enumerate();
for pos, drv in tblDRV do
vF = (drv.."1active") -- i can not use "\active". Workaround:
vFmid = String.Mid(vF, 1, 2);
vF = (vFmid.."\\active")
-------------------------------------------------------------
does_exist = Folder.DoesExist(vF);
if does_exist then
ListBox.InsertItem("ListBox1", -1, vF, "");

tF = Folder.Find(vF, "*", false, nil);
if tF ~= nil then
for i, theFolders in tF do
ListBox.InsertItem("ListBox1", -1, (theFolders), "");
mF = Folder.Find(theFolders, "*", false, nil);
if mF ~= nil then
for g, moreFolders in mF do
ListBox.InsertItem("ListBox1", -1, (moreFolders), "");
end
end
end
ListBox.DeselectItem("ListBox1", LB_ALLITEMS);
end
end
end