I'm looking for a way to paste files with the same names, contained in directories and subdirectories, to another directory with the same subdirectory structure.
For instance :
Dir1/a/a/file1
Dir2/a/a/file1
Those would be pasted into this directory :
Dir3/a/a/file1
Now I found on stackexchange a piece of zsh code that I modified to get the following :
#!/bin/zsh
typeset -A files
for file (dir*/*/*/*(nN)) files[$file:t]+=$file$'\0'
for file (${(k)files}) paste -d "\0" ${(0)files[$file]} > outputDir/*/*/$file
This doesn't work, as the code doesn't understand the "*" after outputDir. If I set a precise set of subdirectories for instance ouputDir/a/a/$file it works like a charm. I don't really know zsh as I discovered it with this piece of code. How could I do to keep the same subdirectories structure for the output dir ?
Thank you for your help. Regards
Dir3/a/a/
already exist? Which of the two original files do you want to keep? You cannot have two files with the same name in the same directory, so you will need to keep one of the two.