I have been looking to all possible answers about "copying file from multiple directories to one single directory" but I cannot find my answer. I need something slightly more specific for my database treatment.
I have a similar question to:
copying files from multiple directory to another multiple directory
but how can I copy these files (they all have exactly the same name) to a new directory and add them the parent directory name, so that I can recognize from which directory they were copied ?
Yes I could copy and rename each of name one after the other, if I hadn't 100 of them :)
I tried loops with find . etc, but still, I cannot add the copied files the parents directory name.
I am still junior in this field, and so I am starting with regex. I guess there is something to do here with them, but I cannot figure out how exactly.
So, this is my question graphically. How to do that with a simple command, or a loop, on my unix terminal:
DIR_a1 --> output_file.bam DIR_a2 --> output_file.bam DIR_a3 --> output_file.bam
NEWDIR_output so that they appear with parent directory name:
output_file_a1.bam output_file_a2.bam output_file_a3.bam
In advance, very thankful for any input