I am trying to copy all the *.psd files, currently in a multi directories structure, into one single directory. Is there an rsync parametrization to allow it?

The solution proposed at Copying files from multiple directories into a single destination directory is not a multilevel recursive directories, only single level subdirectories.

In my current case I have files in multiple recursive directories (up to 7 levels) that I would like to reconcile in a single directory.

2 Answers

choroba On Best Solutions

I fear rsync can't help you here. You can use find to find all the files and copy them to the destination directory, though:

find /path/to/source/topdir -type f -name '*.psd' -exec cp {} /path/to/destination/ \;
myradio On

In my opinion @choroba's answer is the right one.

For completeness (or if for any reason you needed the files to be copied with rsync) you can do something way less efficient using rsync (which is just like using cp in this case), using find, a loop and other things not really necessary.

for file in $(find ./path/to/source/topdir -name "*psd" ); do rsync $file /path/to/destination/; done