Results 1 to 9 of 9

Thread: Compare Files in Directories

  1. #1
    Join Date
    Oct 2008
    Location
    UK
    Beans
    1,816
    Distro
    Ubuntu Mate 22.04 Jammy Jellyfish

    Compare Files in Directories

    I am consolidating my photo collection from multiple directories into one big folder. I am using the command

    find /home/(A) -type f -exec cp {} /home/ (B)/ \;

    to extract all the pictures in the multiple folders in parent folder (A) into the single folder (B). This appears to work very well, after the command has run (B) just contains jpeg files, no files within sub directories. To check everything has gone accross I looked at the Properties of (A) and then (B) - I would have thought that as a folder is not big the size of the folders would be almost the same. However, (A) is 874 items totalling 1.4 GB and (B) is 687 items totalling 1.1 GB. I was hoping to use Meld Diff Veiwer to compare the files in (A) and (B) but it appears Meld does not like binary files. Is there a gui type program I could use to see what is missing? All that should be missing are the sub folders but I can't see they would account for the 0.3 GB difference.

  2. #2
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,499
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Compare Files in Directories

    i suspect there are files with the same name, 2nd file overwrites the 1st
    path1/filename -> /dest/filename
    path2/filename -> /dest/filename
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  3. #3
    Join Date
    Oct 2008
    Location
    UK
    Beans
    1,816
    Distro
    Ubuntu Mate 22.04 Jammy Jellyfish

    Re: Compare Files in Directories

    I don't think so. Before I ran the command to cp all the files into the single folder I selected the multi-directory top level folder in FSlint and made sure there were no duplicate files within the multi folder structure. There were some and I deleted them - so when I ran the Terminal command all the individual files should have been unique.

  4. #4
    Join Date
    Apr 2012
    Beans
    7,256

    Re: Compare Files in Directories

    well I guess you could do something like

    Code:
    $ while read -r -d $'\0' file; do [ -f /home/B/"$file" ] || echo "$file" : not found; done < <(find /home/A -type f -printf '%f\0')

  5. #5

    Re: Compare Files in Directories

    Code:
    diff --brief --recursive --report-identical-files /folder1 /folder2
    Alternate:
    Code:
    diff -qr /somedir/ /someotherdir/
    HTH.
    Windows assumes the user is an idiot.
    Linux demands proof.

  6. #6
    Join Date
    Feb 2008
    Beans
    5,078
    Distro
    Xubuntu 16.04 Xenial Xerus

    Re: Compare Files in Directories

    See Full Circle Magazine, issue 58, page 42.

  7. #7
    Join Date
    Oct 2006
    Location
    New York
    Beans
    1,118
    Distro
    Xubuntu 12.10 Quantal Quetzal

    Re: Compare Files in Directories

    Or count how many unique filenames there are in (A):
    find ~/(A) -type f -exec basename {} \; | sort | uniq | wc -l

    and compare that to how many filenames there are in (A):
    find ~/(A) -type f | wc -l

    @gordintoronto - could you post a link to the pdf since not all of us have that copy, thanks.
    xubuntu minimal, extensive experience, lshw: http://goo.gl/qCCtn
    blog: http://goo.gl/yLg78
    Linux viruses: http://goo.gl/6OCKA

  8. #8
    Join Date
    Feb 2008
    Beans
    5,078
    Distro
    Xubuntu 16.04 Xenial Xerus

    Re: Compare Files in Directories

    Full Circle Magazine, issue 58:

    http://fullcirclemagazine.org/issue-58/

    Page 42 has a story on finding duplicate files. Right-click on the image and select "save as" to get the PDF.

  9. #9
    Join Date
    Oct 2008
    Location
    UK
    Beans
    1,816
    Distro
    Ubuntu Mate 22.04 Jammy Jellyfish

    Re: Compare Files in Directories

    thank you all - I now have many options.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •