Re: program to remove duplicates

Liste des GroupesRevenir à cl c  
Sujet : Re: program to remove duplicates
De : fir (at) *nospam* grunge.pl (fir)
Groupes : comp.lang.c
Date : 21. Sep 2024, 21:12:04
Autres entêtes
Organisation : i2pn2 (i2pn.org)
Message-ID : <4def0af4bef141861014c969c081fc909c878906@i2pn2.org>
References : 1 2 3
User-Agent : Mozilla/5.0 (Windows NT 5.1; rv:27.0) Gecko/20100101 Firefox/27.0 SeaMonkey/2.24
fir wrote:
fir wrote:
fir wrote:
>
>
i think if to write a simple comandline program
that remove duplicates in a given folder
>
i mean some should copy a program to given folder
run it and all duplicates and multiplicates (when
duplicate means a file with different name but
exact binary size and byte content) will be removed
leafting only one for multiplicate set
>
this should work for a big doze of files -
i need it for example i once recovered a hdd disk
and as i got some copies of files on this disc
the removed files are generally multiplicated
and consume a lot of disk space
>
so is there some approach i need to take to make this
proces faster?
>
probably i would need to read list of files and sizes in
current directory then sort or go thru the list and if found
exact size read it into ram tnen compare it byte by byte
>
in not sure if to do sorting as i need write it quick
also and maybe sorting will complicate a bit but not gives much
>
some thoughts?
>
couriously, i could add i once searched for program to remove duplicates
but they was not looking good..so such commandline
(or commandline less in fact as i dont even want toa dd comandline
options maybe) program is quite practically needed
>
>
assuming i got code to read in list of filanemes in given directory
(which i found) what you suggest i should add to remove such duplicates
- the code to read those filenames into l;ist
(tested to work but not tested for being 100% errorless)
>
#include<windows.h>
#include<stdio.h>
>
  void StrCopyMaxNBytes(char* dest, char* src, int n)
  {
   for(int i=0; i<n; i++) { dest[i]=src[i]; if(!src[i]) break;  }
  }
>
  //list of file names
  const int FileNameListEntry_name_max = 500;
  struct FileNameListEntry { char name[FileNameListEntry_name_max]; };
>
  FileNameListEntry* FileNameList = NULL;
  int FileNameList_Size = 0;
>
  void FileNameList_AddOne(char* name)
  {
      FileNameList_Size++;
      FileNameList = (FileNameListEntry*) realloc(FileNameList,
FileNameList_Size * sizeof(FileNameListEntry) );
      StrCopyMaxNBytes((char*)&FileNameList[FileNameList_Size-1].name,
name, FileNameListEntry_name_max);
      return ;
  }
>
>
  // collect list of filenames
  WIN32_FIND_DATA ffd;
>
  void ReadDIrectoryFileNamesToList(char* dir)
  {
   HANDLE h = FindFirstFile(dir, &ffd);
>
   if(!h) { printf("error reading directory"); exit(-1);}
>
   do  {
    if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
      FileNameList_AddOne(ffd.cFileName);
   }
   while (FindNextFile(h, &ffd));
>
  }
>
>
>
int main()
{
>
    ReadDIrectoryFileNamesToList("*");
>
    for(int i=0; i< FileNameList_Size; i++)
        printf("\n %d %s", i, FileNameList[i].name );
>
   return 'ok';
}
ok i skethed some code only i dont know how to remove given file
(given by filename) to some subfolder ..is such dunction in c?

Date Sujet#  Auteur
21 Sep 24 * program to remove duplicates28fir
21 Sep 24 +* Re: program to remove duplicates5fir
21 Sep 24 i`* Re: program to remove duplicates4fir
21 Sep 24 i `* Re: program to remove duplicates3fir
21 Sep 24 i  `* Re: program to remove duplicates2fir
22 Sep 24 i   `- Re: program to remove duplicates1fir
21 Sep 24 +* Re: program to remove duplicates19Chris M. Thomasson
22 Sep 24 i`* Re: program to remove duplicates18fir
22 Sep 24 i +- Re: program to remove duplicates1Chris M. Thomasson
22 Sep 24 i `* Re: program to remove duplicates16Lawrence D'Oliveiro
22 Sep 24 i  +* Re: program to remove duplicates14fir
22 Sep 24 i  i+- Re: program to remove duplicates1Chris M. Thomasson
22 Sep 24 i  i+- Re: program to remove duplicates1Lawrence D'Oliveiro
22 Sep 24 i  i`* Re: program to remove duplicates11Paul
22 Sep 24 i  i +* Re: program to remove duplicates9fir
22 Sep 24 i  i i`* Re: program to remove duplicates8Bart
22 Sep 24 i  i i +* Re: program to remove duplicates3fir
22 Sep 24 i  i i i`* Re: program to remove duplicates2fir
22 Sep 24 i  i i i `- Re: program to remove duplicates1fir
22 Sep 24 i  i i `* Re: program to remove duplicates4fir
22 Sep 24 i  i i  `* Re: program to remove duplicates3fir
22 Sep 24 i  i i   `* Re: program to remove duplicates2fir
22 Sep 24 i  i i    `- Re: program to remove duplicates1fir
22 Sep 24 i  i `- Re: program to remove duplicates1Chris M. Thomasson
22 Sep 24 i  `- Re: program to remove duplicates1DFS
22 Sep 24 +- Re: program to remove duplicates1Lawrence D'Oliveiro
1 Oct 24 `* Re: program to remove duplicates2Josef Möllers
1 Oct 24  `- Off Topic (Was: program to remove duplicates)1Kenny McCormack

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal