Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
What i want to achieve is to extract the files/subfolders of multiple folders and copy/paste them in a new destination folder, if a file exists it should replace it.

Check screenshot below
CleanShot 2022-05-02 at 15.24.43.png
 
Is this what you need?

Nop

I want to select the folders a,b,c or the "src" folder and merge them into a new destination folder.
If a file exists in the destination folder it should replace it with the new file
In the example below, the 1.txt file from folder "a" contains old data and should be replaced with the 1.txt file from folder "c".

PS: By "new file" i dont mean new in terms of date, but new in terms of the order that each folder gets read to process the merging. If the selection of folders was not "a,b,c" but "c,b,a" the final 1.txt file should contain the data of the "a" folder.

Here is a real example on mac
CleanShot 2022-05-02 at 22.38.52.png
 
Doing what you want might require scripting if it's a very large number. But in your example, the easiest way would be to command-select file2.txt and file3.txt and drag them both to folder 1. Even it were hundreds of files, doing it manually probably is quicker than scripting a solution.

Or, from your real example, simply select 1.txt and 2.txt and drag them into dest/subfolder/
 
First draft
Code:
on run {input, parameters}
    set dest to choose folder with prompt "Select destination for merge:"
    set dest_path to (quoted form of (POSIX path of dest))
    repeat with i from 1 to the count of input
        set source_path to (quoted form of (POSIX path of (item i of input)))
        do shell script "rsync -r " & source_path & " " & dest_path
    end repeat
end run
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.