Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find exact duplicated files names in a computer and be able to display the path

Status
Not open for further replies.

titoneon

MIS
Dec 11, 2009
335
US
Hello
I would like to get some guides on how to find in computer named "Cad_server", all duplicated filenames(just those that are exact duplicated) it does not matter what the ext of the file are, as well as the pathname, where those filenames are
Can be possible ?
Thanks a lot in advance
 
Are you sure you want to do this, there are lots of files you wouldn't want to take into account, eg windows system folders.

I think you had already lot of sample code using ADIR() to create an array of files or filer.dll to search files.
eg
thread184-1734682
thread184-1704508

In the last thread you have a solution searching for an entered file name. Now your new problem doesn't need to specifically locate that one file name, which in some sense makes it even simpler. It will take much longer, but you'll search for *.*, all files and then record them in a table, afterwards or while adding single files to the overall table you can locate if a file name (with another path) is already present in the data and list that as double.

So mainly you call the SearchMe Function you defined here:
Code:
Procedure SearchMe
   Lparameters lcPath, lcFile
   * start Searching
   Local loFiler As Filer.fileutil, lnloop, lnCtr, lcPath, lnPaths
   loFiler = Createobject('filer.fileutil')
   With loFiler
      .SearchPath = m.lcPath
      .Subfolder = Thisform.chkSub.Value
      .FileExpression = m.lcFile
      .Find(0)
      For lnloop=1 To .Files.Count
         lcFile = Addbs(.Files(m.lnloop).Path)+.Files(m.lnloop).Name
         Insert Into junk Values (m.lcFile)
      Endfor
   Endwith
   loFiler = .Null.
Endproc
junk should be a table you defined previously to hold a file name per record. You see it pays to use more speaking names and put the definition of everything needed by a code into the code, eg a CREATE TABLE or CREATE CURSOR. I guess a CREATE CURSOR junk (mFile M) would help to get this code running.

You call this with Searchme("C:\","*.*"), SearchMe("D:\","*.*") and all other drives and then INDEX ON JUSTSTEM(junk.mFile) TAG xFirst UNIQUE. Then DELETE ALL and then SET ORDER TO or even DELETE TAG xFirst. The records remaining are the duplicates.

Bye, Olaf.
 
Just checked out and your function fails on ".Subfolder = Thisform.chkSub.Value", as it's missing the rest of the code you didn't posted. You said yourself: "i am using a form that someone already created by using "Define Class Form1 As Form" and so on, all this code i have is into a prg file..." That means you should have the rest of the code.

And one more thing: Since filer has Path and Name separated you could use a cursor "junk" (or a better name) with two fields PAth and Name and store the two separate values separate. Since you want to fund duplicate file names you'd only need to look for doulble values in the name column and can then display all the paths.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top