find the identical files from directories.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ketanm
    New Member
    • Aug 2010
    • 8

    find the identical files from directories.

    Hi all,
    I have to find common files(file name is always changed) from different directories.for eng.
    i have two directories first is c:\dir contains more than one file and second is d:\ddir contains more than one file
    i want output as below.
    1)c:\dir\subdir \filename.txt
    2)d:\ddir\subdi r\filename.txt
    Please let me know how can i achieve this.
  • Oralloy
    Recognized Expert Contributor
    • Jun 2010
    • 988

    #2
    ketanm,

    You have to go through file by file and compare them for equality. I'm not sure there is a Windows command line utility to do that for you.

    So you probably have to do a recursive descent of one of the file structures and compare file-by-file against the other file system. You can use a pattern match or some other basis for base directory prefix conversion. Take a look at opendir and readdir. Alternately, you might try globing.

    Why don't you write out an algorithm and see how it works. Then, when you have specific questions, we can help you some more.

    Comment

    • pradeepkr13
      New Member
      • Aug 2010
      • 43

      #3
      1. read all the files recursively under a directory.
      2. store only filenames (not directories) in a hash as key and value as 1;
      3. Check next file if exists in has unlink it else store it in hash again.

      Comment

      Working...