Results 1 to 10 of 10

Thread: How To Select The Files With Same Name In Two Folders

  1. #1
    Join Date
    Jun 2016
    Beans
    4

    How To Select The Files With Same Name In Two Folders

    Let's guess I have two folders: A & B.

    Now, there are 600+ files in folder A and 400+ files in folder B.

    There are many files which share the same name in these two folders.

    I.E. file.so in folder A and file.so in folder B.

    Now, there are also some files which are not present in both of the folders, I want to ignore them.

    So, is there any software that can do this without much hassle?
    Last edited by Tanuj_Singh; June 1st, 2016 at 12:28 PM.

  2. #2
    Join Date
    Feb 2014
    Beans
    24

    Re: How To Select The Files With Same Name In Two Folders

    Quote Originally Posted by Tanuj_Singh View Post
    Let's guess I have two folders: A & B.

    Now, there are 600+ files in folder A and 400+ files in folder B.

    I want to copy files with same name from folder A to folder B which is very hard if done manually.

    So, is there any software that can do this without much hassle?
    There is an example on this page of a bash script that "compares the files in two directories and lists which files in the first directory are missing from the second", which seems like a good place to start if you want to write a script to do this regularly.

  3. #3
    Join Date
    Jul 2005
    Location
    I think I'm here! Maybe?
    Beans
    Hidden!
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: How To Select The Files With Same Name In Two Folders

    You can not have two files in the same folder if the files are named identically, so I am not sure I understand exactly what you are trying to do; can you explain more please.

    If David above has got nearer what you want you may find that unison (with its gtk GUI if you want it) is helpful.
    Last edited by ajgreeny; June 1st, 2016 at 12:26 PM.

  4. #4
    Join Date
    Jun 2016
    Beans
    4

    Re: How To Select The Files With Same Name In Two Folders

    Quote Originally Posted by ajgreeny View Post
    You can not have two files in the same folder if the files are named identically, so I am not sure I understand exactly what you are trying to do; can you explain more please.
    No, I already said there are two folders, A and B.

  5. #5
    Join Date
    Aug 2011
    Location
    52.5° N 6.4° E
    Beans
    6,822
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: How To Select The Files With Same Name In Two Folders

    Sounds to me as updating files in dir B from files in dir A. You could use rsync with the option --existing:
    Code:
    rsync --existing /path/to/dirA/* /path/to/dirB/

  6. #6
    Join Date
    Oct 2006
    Beans
    58,286

    Re: How To Select The Files With Same Name In Two Folders

    Quote Originally Posted by Tanuj_Singh View Post
    Let's guess I have two folders: A & B.
    Is this a hypothetical question or do you have an actual issue ?

    Now, there are 600+ files in folder A and 400+ files in folder B. I want to copy files with same name from folder A to folder B which is very hard if done manually...
    Are you saying that you want to copy files from folder A, to folder B which already contains files with the same name as in folder A, but different file contents.

    Your post is as clear as mud.

  7. #7
    Join Date
    Jun 2016
    Beans
    4

    Re: How To Select The Files With Same Name In Two Folders

    Quote Originally Posted by Impavidus View Post
    Sounds to me as updating files in dir B from files in dir A. You could use rsync with the option --existing:
    Code:
    rsync --existing /path/to/dirA/* /path/to/dirB/
    Awesome, that did it. Thank you

  8. #8
    Join Date
    Dec 2007
    Beans
    12,521

    Re: How To Select The Files With Same Name In Two Folders

    You could have had the courtesy to give impavidus credit in your Ask Ubuntu answer !!!

  9. #9
    Join Date
    Jun 2016
    Beans
    4

    Re: How To Select The Files With Same Name In Two Folders

    Quote Originally Posted by vasa1 View Post
    You could have had the courtesy to give impavidus credit in your Ask Ubuntu answer !!!
    Sorry, I've given the credit. I was so into getting the work done that I forgot.

  10. #10
    Join Date
    Dec 2007
    Beans
    12,521

    Re: How To Select The Files With Same Name In Two Folders

    Quote Originally Posted by Tanuj_Singh View Post
    Sorry, I've given the credit. I was so into getting the work done that I forgot.
    Great

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
  •