Web lists-archives.com

Re: any program that search for same files?

Thank David for your encouragement!

i have little experience with script
i prefer to use java

i have read reference guide for debian packaging
i'm afraid i can't become package developer

maybe the only user of my program is me
anyway i write a java method today
it search all files in directory d and store them in Vector v1;

 public findsame(File d)
   {String a[],s; File f,p; int i; Vector v1=new Vector();
     Vector v2=new Vector(); v2.addElement(d);
     {if(v2.size()==0) break;
      f=(File)v2.lastElement(); v2.remove(v2.size()-1);
      a=f.list(); for(i=0;i<a.length;i++)
        p=new File(s); if(p.isFile()) v1.addElement(s);
        if(p.isDirectory())    v2.addElement(p);

On Wednesday, October 17, 2018 12:12 PM, David Christensen <dpchrist@xxxxxxxxxxxxxxxx> wrote:

On 10/14/18 3:06 PM, Long Wind wrote:
> given two directories, the program can print files that are in both
> directories
> to make it easy, if file name and size are same, then they are same
> i've to admit my memory is poor, if good, who need such program?
> i'm about to write it in java, it can be completed in a few hours but
> i think there might be simple solution

On 10/14/18 3:19 PM, The Wanderer wrote:
> Sounds like a perfect case for rdfind.

On 10/14/18 3:39 PM, Håkon Alstadheim wrote:
> fdupes or jdupes fit the bill.

On 10/14/18 6:11 PM, Erik Christiansen wrote:
> What I use with full satisfaction is just "diff -qr dir1 dir2"...

On 10/15/18 8:14 AM, Andrew McGlashan wrote:
> diff -s

On 10/16/18 12:53 AM, Long Wind wrote:
> it seems all those packages compare contents of files but my
> definition of same file is same name and size and should run much
> fast
> and they seem to search all directories for same files and this is
> different from my requirement
> my ideal program should take two directories as argument and print

> files that are in both directories

> i don't care same files within one directory
> my ideal program can also take one directory as argument and print
> same file in it if more than two directories are given, then first
> directory is searched, all files that are also in other directories
> are printed
> it seems i have to write it in java
> is there users' interest for such program?

It sounds like you want a script to meet your specific needs.

It is my belief that writing a general-purpose file system metadata
search utility is a non-trivial task.  Take a look at find(1) to get an
idea of the scope of the most obvious related utility:


Here is a Perl 5 script I wrote years ago to compare the modification
times of same-named files in two directory trees:


It could be modified to meet your requirements.

I suggest that you start at the small end -- writing scripts to meet
specific needs:

1.  Pick a scripting language.

2.  Define the requirements of the script.

3.  Design, construct, test, debug, and document the script.

4.  Integrate the script into your system administration processes.

Bonuses include:

1.  Use a version control system.

2.  Use an issue tracking system.

While you could use Java, understand that a Java runtime environment
must be installed for Java apps to work.  sh, bash, perl, and/or python
are supported OOTB by many OS distributions, which makes it easier to
run your scripts inside fresh install, rescue, live, and other
restricted environments.